欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【基于自定义Unity生存期模型PerCallContextLifeTimeManager的问题】,下面是详细的讲解!
基于自定义Unity生存期模型PerCallContextLifeTimeManager的问题
private static void TestPerCallContextLifeTimeManager()
{
IExample example;
using (IUnityContainer container=new UnityContainer())
{
container.RegisterType(typeof(IExample), typeof(Example),
new PerCallContextLifeTimeManager());
container.Resolve<IExample>().SayHello();
container.Resolve<IExample>().SayHello();
Action<int> action=delegate(int sleep)
{
container.Resolve<IExample>().SayHello();
Thread.Sleep(sleep);
container.Resolve<IExample>().SayHello();
};
Thread thread1=new Thread((a)=> action.Invoke((int)a));
Thread thread2=new Thread((a)=> action.Invoke((int)a));
thread1.Start(50);
thread2.Start(55);
thread1.Join();
thread2.Join();
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 50);
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 55);
Thread.Sleep(100);
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 50);
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 55);
Thread.Sleep(100);
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 50);
ThreadPool.QueueUserWorkItem((a)=> action.Invoke((int)a), 55);
Thread.Sleep(100);
example=container.Resolve<IExample>();
}
example.SayHello();
Console.ReadKey();
}
关于基于自定义Unity生存期模型PerCallContextLifeTimeManager的问题的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【ASP】ASP.NET中内嵌页面代码的一个问题-NET-内
- 【As】Asp.net中的页面乱码的问题-sp--pn-ne-et
- 【增加记录】asp.net中获取新增加记录的ID Access
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【404页面】ASP.NET设置404页面返回302HTTP状态码
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
