The lifetime of an instance of a WCF service?

后端 未结 4 1034
南方客
南方客 2021-01-05 12:03

in the process of creating a WCF service I ran into a term that\'s new to me. Basically when specifying the InstanceContextMode I have a few options, including;

4条回答
  •  清酒与你
    2021-01-05 12:22

    InstanceContextMode.Single corresponds to a singleton service i.e. the service instance server side is the same for all the incoming requests.

    A few comments:

    • You service might be terminated by the host even if it is a singleton, that's probably the case if your service is hosted in iis
    • It's the instance context which is a singleton which might be dissociated from the actual service instances (but let's keep it simple for now...)
    • If an exception is not caught properly in a singleton service, it might prevent any subsequent request to succeed

提交回复
热议问题