Tag: servicebehavior

WCF ConcurrencyMode Single和InstanceContextMode PerCall

我的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 这可能吗? […]