// Shared variable: text_buffer_sv // This is shared between the background thread that is // generating the text, and the GUI thread that is // displaying the text. #region Loading and saving settings public WindowsBackup_App(TextBox Output_tb, Forms.NotifyIcon notify_icon, Icon ready, Icon busy, Icon error) { this.Output_tb = Output_tb; this.notify_icon = notify_icon; ready_icon = ready; busy_icon = busy; error_icon = error; if (File.Exists(settings_path) == false) { create_default_file(); // Dispose the objects so to recreate from file later file_name_reg.Dispose(); } try { // The "delay_thread" needs to be constructed first, before calling "read_settings()". // The reason is that if there is an error inside "read_settings()", // then the "delay_thread" is used to write messages to the "Output_tb". delay_thread = new DelayThread(Output_tb, new Func_void(add_text_to_Output_tb)); read_settings(); backup_manager.start_live_backup(); } catch (Exception ex) { handle_event(AppEventType.ERROR, new object[] { ex.Message }); } }
protected virtual void Dispose(bool disposing) { ReleaseUnmanagedResources(); if (disposing) { if (WorkBytesEvent != null) { WorkBytesEvent.Dispose(); } if (OrigBytesEvent != null) { OrigBytesEvent.Dispose(); } if (DelayBytesEvent != null) { DelayBytesEvent.Dispose(); } if (WorkEnergyEvent != null) { WorkEnergyEvent.Dispose(); } if (FreqWaveEvent != null) { FreqWaveEvent.Dispose(); } if (OrigThread != null) { OrigThread.Abort(); if (OrigThread.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } if (DelayThread != null) { DelayThread.Abort(); } if (WorkThread != null) { WorkThread.Abort(); if (WorkThread.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } if (EnergyThread != null) { EnergyThread.Abort(); } if (FreqThread != null) { FreqThread.Abort(); } } }