private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { logger.TextAddedEvent -= loggerTextAddedEventHandler; logger.FinishLog(); timer.Tick -= timerTickHandler; if (timer.IsRunning) { timer.Stop(); } timer.Dispose(); if (gnssEmulatorPort != null) { if (gnssEmulatorPort.IsOpen) { gnssEmulatorPort.Close(); } gnssEmulatorPort.Dispose(); } if (gtrPort.IsOpen) { gtrPort.NewNMEAMessage -= gtrPortNewNMEAMessageEventHandler; gtrPort.PortError -= gtrPortErrorEventHandler; gtrPort.Close(); } }
public void Dispose() { if (!disposing) { disposing = true; if (port != null) { if (port.IsOpen) { try { port.Close(); } catch { } } port.Dispose(); } if (timer != null) { if (timer.IsRunning) { timer.Stop(); } timer.Dispose(); } if (node != null) { node.Stop(); } } }
// Detaches from events, stops, and disposes of the dump timer. Timers created // through the CreateDumpTimer method should be released through this method. private void ReleaseDumpTimer(PrecisionTimer dumpTimer) { if (dumpTimer != null) { dumpTimer.Tick -= DumpTimer_Tick; dumpTimer.Stop(); dumpTimer.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { #region timer if (timer.IsRunning) { timer.Stop(); } timer.Dispose(); #endregion #region inPorts if (inPorts != null) { try { inPorts.Close(); } catch { } inPorts.Dispose(); } #endregion #region outPort if (outPort != null) { if (outPort.IsOpen) { try { outPort.Close(); } catch { } } outPort.Dispose(); } #endregion } disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { if (timer.IsRunning) { timer.Stop(); } timer.Dispose(); if (inPort.IsOpen) { try { inPort.Close(); } catch { } } inPort.Dispose(); if (AUXGNSSUsed) { try { auxGNSSPort.Close(); } catch { } auxGNSSPort.Dispose(); } if (OutPortUsed) { if (outPort.IsOpen) { try { outPort.Close(); } catch { } } outPort.Dispose(); } } disposed = true; } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { if (IsOpen) { Close(); } port.Dispose(); timer.Dispose(); } disposed = true; } }
private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { if (timer != null) { timer.Dispose(); } if (port != null) { port.Dispose(); } } disposed = true; } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="PrecisionInputTimer"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> private void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { if ((object)m_timer != null) { m_timer.Tick -= m_timer_Tick; m_timer.Dispose(); } m_timer = null; if ((object)m_frameWaitHandleA != null) { m_frameWaitHandleA.Set(); m_frameWaitHandleA.Dispose(); } m_frameWaitHandleA = null; if ((object)m_frameWaitHandleB != null) { m_frameWaitHandleB.Set(); m_frameWaitHandleB.Dispose(); } m_frameWaitHandleB = null; } } finally { m_disposed = true; // Prevent duplicate dispose. } } }