简体   繁体   English

WCF服务方法是否具有与ASP.NET Application_EndRequest等效的功能?

[英]Does WCF service method have something equivalent to ASP.NET Application_EndRequest?

I want to Dispose of some objects that are created during a WCF service method, but I need to clean them up outside of the scope of the method that created them. 我想Dispose在WCF服务方法期间创建的一些对象,但是我需要在创建它们的方法范围之外清理它们。 When I'm working in ASP.NET, I normally call that code during the Application_EndRequest event. 在ASP.NET中工作时,通常在Application_EndRequest事件期间调用该代码。

If the answer is: there is no Application_EndRequest -like event in WCF, how should I go about cleaning up my objects? 如果答案是:WCF中没有类似Application_EndRequest的事件,我应该如何清理对象?

You can implement IDisposable for your WCF service. 您可以为WCF服务实现IDisposable If the service is configured PerSession or PerCall * context mode * dispose method will be called once the channel is closed and the service instance is dropped. 如果服务被配置PerSessionPerCall * 上下文模式 *处置一旦信道被关闭方法将被调用,该服务实例被丢弃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM