WCF 线程休眠 [英] WCF Thread Sleep

查看:37
本文介绍了WCF 线程休眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 服务,它为 WCF 服务启动一个主机.我有一个定义 ServiceContract 和 OperationContracts 的接口.有一个类实现了这个接口.ServiceBehavior 属性是 PerSession.据我了解,每个会话在 WCF 服务上都有自己的类实例.

I have a windows service that starts a host for a WCF service. I have an interface defining the ServiceContract and OperationContracts. There is a class that implements this interface. The ServiceBehavior attribute is PerSession. As I understand, each session get its own class instance on the WCF service.

[ServiceBehavior(InstanceContextMode = ServiceModel.InstanceContextMode.PerSession)]
public class WCFServiceImplementation : WCFServiceInterface
{

}

现在在我的 WCFServiceImplementation 中,我正在调用 Threading.Thread.Sleep(1000)(有一些竞争条件).我的问题 - 当线程处于睡眠状态时,其他客户端是否仍可以调用该服务?我对线程不是很熟悉,是否每个类实例都在自己单独的线程上运行 WCF 服务.

Now some where in my WCFServiceImplementation I am calling Threading.Thread.Sleep(1000) (there are some race conditions). My question - can the service still be called by other clients while the thread is in sleep? I am not very familiar with threading, does each class instance run on its own separate thread with WCF services.

推荐答案

是的,该服务仍然可以被其他客户端调用,因为他们将在其他会话中.

Yes, the service can still be called by other clients because they will be on other sessions.

这篇关于WCF 线程休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆