WCF合同实例 [英] WCF Contract Instance
问题描述
嗨
在Windows服务中,我正在parallel.foreach循环中创建WCF服务协定的实例.
在这种识别/验证方法中,它是在循环中每次创建一个新实例还是使用现有实例.
我们能否使用调试代码或跟踪来找到它
谢谢
Abinesh
>>每次在循环中创建一个新实例还是使用现有实例?
这个实例是什么意思?是客户端对象还是服务对象?我认为您的意思是服务合同实例.如果是这样,则取决于您如何设置InstanceContextMode.
共有三种模式.
PerCall:为每个客户端请求创建一个新的InstanceContext(以及服务对象).
PerSession:为每个新的客户端会话创建一个新的InstanceContext(并因此创建服务对象),并在该会话的整个生命周期内对其进行维护(这需要支持会话的绑定).
单个:单个InstanceContext(以及相应的服务对象)处理应用程序生命周期内的所有客户端请求.
您可以参考下面的链接以获取更多信息.
#实例化
https://msdn. microsoft.com/en-us/library/ms731193%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
Hi
In my windows service, I am creating instance of a WCF Service contract within the parallel.foreach loop.
In this how to identify/verify, does it creates a new instance every time within the loop or uses the existing instance.
Can we able to find this using the Debugging the code or tracing
Thanks,
Abinesh
>> does it creates a new instance every time within the loop or uses the existing instance.
What do you mean by this instance? Is it client object or service object? I assume you mean service contract instance. If so, it depends on how you set InstanceContextMode.
There are three modes.
PerCall: A new InstanceContext (and therefore service object) is created for each client request.
PerSession: A new InstanceContext (and therefore service object) is created for each new client session and maintained for the lifetime of that session (this requires a binding that supports sessions).
Single: A single InstanceContext (and therefore service object) handles all client requests for the lifetime of the application.
You could refer the link below for more information.
# Instancing
https://msdn.microsoft.com/en-us/library/ms731193%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
这篇关于WCF合同实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!