WCF中的Percall和persession [英] Percall and persession in WCF
本文介绍了WCF中的Percall和persession的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我正在研究WCF中的percall和persession我创建了一个客户端并在我使用两个实例管理时托管我得到相同的输出
So i am working on percall and persession in WCF i have created a client and hosted when i am working with both instance managements i am getting the same output
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class Service1 : IService1
{
private int count = 0;
public int countlevel()
{
count ++;
return count;
}
}
class Program
{
static void Main(string[] args)
{
ServiceReference1.Service1Client fd = new ServiceReference1.Service1Client();
for (int i = 1; i <= 5; ++i)
{
Console.WriteLine(string.Format("Service called: {0} times, Return value: {1}", i, fd.countlevel()));
}
Console.ReadLine();
}
但我的输出为1,1,1,1 for persession也在哪里我做错了?
But i am getting the output as 1,1,1,1 for persession also where i am doing wrong??
推荐答案
我得到这个输出
服务叫做:1次,返回值:1
服务电话:2次,返回值:2
服务电话:3次,返回值:3
服务电话:4次,返回值:4
服务电话:5次,返回值:5
完全复制代码。 ..不知道你怎么得到1,1,1,1
这也与服务行为属性无关。
I am getting this output
Service called: 1 times, Return value: 1
Service called: 2 times, Return value: 2
Service called: 3 times, Return value: 3
Service called: 4 times, Return value: 4
Service called: 5 times, Return value: 5
Code copied exactly... donno how you are getting 1,1,1,1
Also this is regardless of the service behavior attribute.
这篇关于WCF中的Percall和persession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文