Clean up event handler leaks
- Issue MatterHackers/MCCentral#5573 Investigate allocations on large GCode load and failure to release
This commit is contained in:
parent
f678cd688b
commit
c8510bdd6d
3 changed files with 41 additions and 13 deletions
|
|
@ -27,6 +27,7 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
|
|
@ -67,14 +68,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
};
|
||||
this.AddChild(pendingTasksList);
|
||||
|
||||
var tasks = ApplicationController.Instance.Tasks;
|
||||
// Register listeners
|
||||
ApplicationController.Instance.Tasks.TasksChanged += this.Tasks_TasksChanged;
|
||||
|
||||
tasks.TasksChanged += (s, e) =>
|
||||
{
|
||||
RenderRunningTasks(theme, tasks);
|
||||
};
|
||||
this.RenderRunningTasks(theme, ApplicationController.Instance.Tasks);
|
||||
}
|
||||
|
||||
RenderRunningTasks(theme, tasks);
|
||||
private void Tasks_TasksChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.RenderRunningTasks(theme, ApplicationController.Instance.Tasks);
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
// Unregister listeners
|
||||
ApplicationController.Instance.Tasks.TasksChanged -= this.Tasks_TasksChanged;
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
private void RenderRunningTasks(ThemeConfig theme, RunningTasksConfig tasks)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue