void formBackgroundPatcher_Disposed(object sender, EventArgs e) { if (taskBar != null) { taskBar.Dispose(); taskBar = null; } }
public formBackgroundPatcher(Form parent) { InitializeComponents(); this.parent = parent; var h = this.Handle; taskBar = new Windows.Taskbar(); lang = new Label[] { labelLang1, labelLang2, labelLang3, labelLang4 }; foreach (var l in lang) { l.Click += langSelect_Click; } labelLang.Text = LANG[GetLang()]; labelTime.Text = ""; panelAdvanced.SetContent(panelAdvancedContent); var bp = Tools.BackgroundPatcher.Instance; bp.DownloadProgress += bp_DownloadProgress; bp.Error += bp_Error; bp.Complete += bp_Complete; bp.Starting += bp_Starting; bp.StateChanged += bp_StateChanged; if (Settings.BackgroundPatchingMaximumThreads.HasValue) { sliderThreads.Value = (float)(Settings.BackgroundPatchingMaximumThreads.Value - THREADS_MIN) / THREADS_MAX; } else { sliderThreads.Value = (float)(10 - THREADS_MIN) / THREADS_MAX; } PatchingSpeedLimit_ValueChanged(Settings.PatchingSpeedLimit, null); PatchingOptions_ValueChanged(Settings.PatchingOptions, null); Settings.BackgroundPatchingEnabled.ValueChanged += BackgroundPatchingEnabled_ValueChanged; Settings.PatchingSpeedLimit.ValueChanged += PatchingSpeedLimit_ValueChanged; Settings.PatchingOptions.ValueChanged += PatchingOptions_ValueChanged; UpdateStatus(); this.Disposed += formBackgroundPatcher_Disposed; }