我有我的服務下面的代碼:終身異步委託調用的
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)以查看會發生什麼? –