private void BlinkCallback(object state) { try { LineDisplaySimulator sim = wr.Target as LineDisplaySimulator; if (sim != null) { if (sim.State != ControlState.Closed && sim.DeviceEnabled) { // toggle the BlinkOn variable and update the device sim.blinkon = !sim.blinkon; sim.Window.Blink(sim.blinkon); } } } catch { // Eat all exceptions here because the timer may get called while the device // is shutting down or when ScreenMode is changing and the simulator window is // be destroyed and recreated. } }
public BlinkTimerClass(LineDisplaySimulator sim) { wr = new WeakReference(sim); blinkTimer = new System.Threading.Timer(new TimerCallback(BlinkCallback), null, Timeout.Infinite, Timeout.Infinite); }
public LineDisplaySimulatorWindow(LineDisplaySimulator serviceObject) : base(serviceObject) { Invoke(new MethodDelegate(InitializeComponent)); }