public void Update(LiquesceSvcState state, string message) { SetStateDelegate handler = setStateDelegate; if (handler != null) { handler(state, message); } }
private void SetState(LiquesceSvcState state, string text) { notifyIcon1.BalloonTipText = text; switch (state) { case LiquesceSvcState.InWarning: notifyIcon1.Text = "Liquesce State Warning"; notifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; break; case LiquesceSvcState.Unknown: notifyIcon1.Text = "Liquesce State Unknown"; notifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; break; case LiquesceSvcState.Running: notifyIcon1.Text = "Liquesce State Running"; notifyIcon1.BalloonTipIcon = ToolTipIcon.None; break; case LiquesceSvcState.Stopped: notifyIcon1.Text = "Liquesce State Stopped"; notifyIcon1.BalloonTipIcon = ToolTipIcon.Info; break; case LiquesceSvcState.InError: notifyIcon1.Text = "Liquesce State In Error"; notifyIcon1.BalloonTipIcon = ToolTipIcon.Error; break; default: notifyIcon1.Text = "Liquesce State Unknown"; Log.Error("SetState has an unknown state value [{0}]", state); notifyIcon1.BalloonTipIcon = ToolTipIcon.None; break; } if (state != lastState) { lastState = state; notifyIcon1.ShowBalloonTip(5000); } }
internal void FireStateChange(LiquesceSvcState newState, string message) { try { state = newState; Log.Info("Changing newState to [{0}]:[{1}]", newState, message); using (subscribersLock.ReadLock()) { // Get all the clients in dictionary var query = (from c in subscribers select c.Value).ToList(); // Create the callback action Action <IStateChange> action = callback => callback.Update(newState, message); // For each connected client, invoke the callback query.ForEach(action); } } catch (Exception ex) { Log.ErrorException("Unable to fire state change", ex); } }