WCF深入学习_并发管理(四)
2011-04-07 15:58
330 查看
一.实例说明
(4.Instance mode =PerSession and Concurrency =Multiple)实例模式'PerSession'与并发'Multiple'。
In this combination one WCF instance is created for every WCF client session and every method call is run over multiple threads. Below is the pictorial representation of the same.
二.代码分析
三.运行结果分析
If you run the sample code attached with this article you will find same instance with every method call running on different methods.
To get a better idea you can run with different client exe instance with different names as shown below. You can notice how every client get his own WCF service instance with every method allocated to run on different threads.
(4.Instance mode =PerSession and Concurrency =Multiple)实例模式'PerSession'与并发'Multiple'。
In this combination one WCF instance is created for every WCF client session and every method call is run over multiple threads. Below is the pictorial representation of the same.
二.代码分析
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Description; using System.Threading; namespace ClassLibrary1 { [ServiceContract] public interface IHelloWorldService { [OperationContract(IsOneWay = true)] void Call(string ClientName); } [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)] public class HelloWorldService : IHelloWorldService { public int i; public void Call(string ClientName) { i++; Console.WriteLine("Client name :" + ClientName + " Instance:" + i.ToString() + " Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + " Time:" + DateTime.Now.ToString() + "/n/n"); Thread.Sleep(5000); } } }
三.运行结果分析
If you run the sample code attached with this article you will find same instance with every method call running on different methods.
To get a better idea you can run with different client exe instance with different names as shown below. You can notice how every client get his own WCF service instance with every method allocated to run on different threads.
相关文章推荐
- WCF深入学习_并发管理(五)
- WCF深入学习_并发管理(三)
- WCF深入学习_并发管理(二)
- WCF深入学习_并发管理(六)
- WCF深入学习_并发管理(一)
- 《WCF按部就班学习系列8_WCF并发管理概述》(上)
- 《WCF按部就班学习系列8_WCF并发管理概述》(下)
- WCF学习(七)--并发2
- iOS深入学习(使用CocoaPods进行第三方资源管理)
- 深入理解JVM学习笔记-自动内存管理机制
- WCF学习之:ConcurrencyMode 并发模型
- 二,从ConcurrentHashMap类学习高并发程序的设计思路【深入JDK源码】
- 深入学习java并发编程:内存模型(五)锁
- WCF笔记--并发管理
- MySQL:列类型深入学习及表管理(一)
- UNIX环境编程学习笔记(19)——进程管理之fork 函数的深入学习
- WCF服务3——深入学习
- [android深入学习]android窗口管理机制
- MySQL:列类型深入学习及表管理(二)
- C++并发编程学习——2.管理线程