Basically there are three instance modes in WCF:
- Per-Call instance mode
- Per-Session instance mode
- Singleton Instance Mode
Configuration:
Instance mode can be configured using ServiceBehavior attribute. This can be specified at implementing the service contract as shown below. [ServiceContract()]
public interface IMyService
{
[OperationContract]
int MyMethod();
}
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class MyService:IMyService
{
public int MyMethod()
{
//Do something
}
}
No comments:
Post a Comment