refer to http://www.c-sharpcorner.com/uploadfile/f6c0e9/wcf-instance-management/
WCF framework has provided 3 ways by which we can manage WCF service instance creation.
Per-Call
Per-Session
Single
//[ServiceInstanceContextMode = InstanceContextMode.PerCall)] //[ServiceInstanceContextMode = InstanceContextMode.PerSession)] [ServiceInstanceContextMode = InstanceContextMode.Single)] class MyService : IMyContract,IDisposable { static int m_Counter = 0; public int MyMethod( ) { m_Counter++; return m_Counter; } }
转载于:https://blog.51cto.com/laynewang/1196452