/// <summary> /// Sets the led status (just set, no blink) /// </summary> /// <param name="pValue"></param> private void SetStatus(byte pValue) { try { Console.WriteLine(string.Format("Send arbitrary data {0:X2} and answer is ", pValue) + TricolorUsbSignal.SendRawBuffer(new byte[] { Constants.PACKET_ID, pValue })); if (mLastSendCharWasError) { DoLogLine("SUCCESS while sending data to Blink. Reconnected?"); this.mSystrayIcon.ShowBalloonTip(2000, "Tricolor USB Signal", "Connected to USB signal.", ToolTipIcon.Info); } mLastSendCharWasError = false; } catch (Exception ex) { if (!mLastSendCharWasError) { DoLogLine("ERROR while sending data to Blink. Disconnected?"); this.mSystrayIcon.ShowBalloonTip(2000, "Tricolor USB Signal", "Connection lost to USB signal!", ToolTipIcon.Error); try { TricolorUsbSignal.Close(); } catch (Exception ex2) { DoLogLine("ERROR while closing connection to Blink. Ignore and release."); Console.WriteLine("ERROR SendChar() - Close(): " + ex.Message); } finally { mTricolorUsbSignal.Dispose(); mTricolorUsbSignal = null; } } mLastSendCharWasError = true; Console.WriteLine("ERROR SendChar(): " + ex.Message); } }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). Blink1.Set(Color.Black); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. Blink1.Dispose(); disposedValue = true; } }