private void MainForm_Load(object sender, EventArgs e) { // Create CANoeAccess object mCANoeAccess = new CANoeAccess(); // Register for events of CANoeAccess object mCANoeAccess.DeckStatusReceived += new EventHandler(CANoeAccess_DeckStatusReceived); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { // Unregister from events of CANoeAccess object mCANoeAccess.DeckStatusReceived -= new EventHandler(CANoeAccess_DeckStatusReceived); // Release COM interfaces and perform cleanup in CANoeAccess object mCANoeAccess.Dispose(); mCANoeAccess = null; }