开发者

When do static objects in WCF server get disposed?

Here is my scenario: I have a static object which will connect to a concurrent license service to get a license. I will need this license on some of the non-static methods in my WCF service.

The problem here is, I know this static object will r开发者_开发技巧emain around and the license will be held for as long as this object is in use. But I also need to Release this license before the static object is disposed by calling a release method to the concurrent license service.

If I don't release the license held in the static object, the concurrent license service will refuse to reissue the license again after some idle time which I can not control...

Now comes the question. Is there an Event in WCF server side to let me know that IIS or whatever is about to dispose or recycle the static objects so I can Release the license in the concurrent license service before its disposed or recycled???

And what are the things I should be keeping in mind when dealing with this static object; should I be using Lock() or Using()??

In other words, is there a way to make a static destructor for this case? This destructor should most likely be called by IIS.


You could solve your issue by moving to a singleton pattern where the single instance is an idisposable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜