我有一个关于WCF服务配置的问题。
我希望每次调用我的服务都会创建一个新的服务实例。
对于并发性,我希望在一个调用完成之前不会启动另一个调用。
因此,如果我的服务如下所示:
因此,如果我的服务如下所示:
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single,
InstanceContextMode=InstanceContextMode.PerCall)]
public class MyService: IMyService
{
public bool MyServiceOp()
{
Debug.WriteLine("thread "+
Thread.CurrentThread.ManagedThreadId.ToString());
Debug.WriteLine("start operation ");
Do_work()
Debug.WriteLine("end operation");
return true;
}
}
在我用循环多次调用它时,跟踪结果如下:
thread 1
thread 2
start operation
start operation
end operation
end operation
虽然我希望拥有这个:
thread 1 start operation end operation
thread 2 start operation end operation
这个可能吗?谢谢