OpenHardwareMonitor.GUI.SensorNotifyIcon.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            Icon icon = notifyIcon.Icon;
              notifyIcon.Icon = null;
              if (icon != null)
            icon.Dispose();
              notifyIcon.Dispose();

              if (brush != null)
            brush.Dispose();
              if (darkBrush != null)
            darkBrush.Dispose();
              pen.Dispose();
              graphics.Dispose();
              bitmap.Dispose();
        }

Usage Example

        private void Remove(ISensor sensor, bool deleteConfig)
        {
            if (deleteConfig)
            {
                Config.Remove(
                    new Identifier(sensor.Identifier, "tray").ToString());
                Config.Remove(
                    new Identifier(sensor.Identifier, "traycolor").ToString());
            }
            SensorNotifyIcon instance = null;

            foreach (SensorNotifyIcon icon in list)
            {
                if (icon.Sensor == sensor)
                {
                    instance = icon;
                }
            }
            if (instance != null)
            {
                list.Remove(instance);
                UpdateMainIconVisibilty();
                instance.Dispose();
            }
        }
All Usage Examples Of OpenHardwareMonitor.GUI.SensorNotifyIcon::Dispose