我有我的服务下面的代码:终身异步委托调用的
protected override void OnStart(string[] args)
{
var cleaner = new Cleaner();
Action action = cleaner.Run;
action.BeginInvoke(null, null);
}
我很担心,我是否应该委托移动到一个实例变量,因为它使用可能被GC收集的对象,因为他们只在本地创建。
我有我的服务下面的代码:终身异步委托调用的
protected override void OnStart(string[] args)
{
var cleaner = new Cleaner();
Action action = cleaner.Run;
action.BeginInvoke(null, null);
}
我很担心,我是否应该委托移动到一个实例变量,因为它使用可能被GC收集的对象,因为他们只在本地创建。
您是否尝试调用[GC.Collect()](http://msdn.microsoft.com/zh-cn/library/xe0c2357.aspx)以查看会发生什么? –