Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool
return void
Esempio n. 1
0
        // This procedure is where the actual cleanup occurs
        private void Dispose(bool disposing)
        {
            try
            {
                // Exit now if the object has already been disposed
                if (disposed)
                {
                    return;
                }

                if (disposing)
                {
                    // The object is being disposed, not finalized.
                    // It is safe to access other objects (other than the mybase object)
                    // only from inside this block
                    _ourSettingsControl.SkipRegexCheckBox.CheckedChanged         -= SkipRegexChanged;
                    _ourSettingsControl.SkipRegexTextBox.TextChanged             -= SkipRegexChanged;
                    _ourSettingsControl.TemplateNameTextBox.TextChanged          -= TemplateNamesChanged;
                    _ourSettingsControl.HasAlternateNamesCheckBox.CheckedChanged -= TemplateNamesChanged;
                    _ourSettingsControl.AlternateNamesTextBox.TextChanged        -= TemplateNamesChanged;
                    _ourSettingsControl.PropertiesButton.Click -= PropertiesButtonClick;
                    ShowHideOurObjects(false);

                    _ourTab.Dispose();

                    _ourSettingsControl.Goodbye();
                    _ourSettingsControl.Dispose();

                    PluginManager.AWBForm.PluginsToolStripMenuItem.DropDownItems.Remove(OurMenuItem);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                // Perform cleanup that has to be executed in either case:
                _ourTab                    = null;
                OurMenuItem                = null;
                TheArticle                 = null;
                Template                   = null;
                MainRegex                  = null;
                SecondChanceRegex          = null;
                PreferredTemplateNameRegex = null;
                _ourTab                    = null;
                _ourSettingsControl        = null;
                _deleteMeMenuItem          = null;
                SkipRegex                  = null;

                // Remember that this object has been disposed of:
                disposed = true;
            }
        }