private void WorkerThreadCallback() { do { try { if (this.cyclicMrEvent.WaitOne(this.Intervall * 10)) { this.cyclicMrEvent.Reset(); this.CallOnUpdateTick(); } else { Thread.Sleep(10); } } catch (ThreadAbortException ex) { Thread.ResetAbort(); this.runWorker = false; } }while (this.runWorker); if (this.CallEvent(this.hdOnDisable)) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle; } else { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle; this.SetError(); } }
public bool Enable() { lock (this.syncObject) { if (this.Remove || this.tickerState != PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle) { return(false); } this.Ready = false; this.Error = false; this.runWorker = true; if (this.thrHdlCallBack != null) { this.thrHdlCallBack.Abort(); this.thrHdlCallBack = (Thread)null; } this.thrHdlCallBack = new Thread(new ThreadStart(this.WorkerThreadCallback)) { Priority = this.Priority }; this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Enable; this.thrHdlCallBack.Start(); return(true); } }
private void ExecuteDisable() { lock (this.syncObject) { this.TerminateThread(); this.Ready = false; this.Error = false; this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle; } }
internal Ticker(string name, int intervall, ThreadPriority threadPrio) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle; this.Name = name; this.Intervall = intervall; this.Priority = threadPrio; this.Error = false; this.Ready = false; ++PhoenixContact.Common.Ticker.Ticker.sequentialNumber; if (!string.IsNullOrEmpty(name)) { return; } this.Name = string.Format("Ticker_{0}", (object)PhoenixContact.Common.Ticker.Ticker.sequentialNumber.ToString((IFormatProvider)CultureInfo.InvariantCulture)); }
public bool DisableAsync() { lock (this.syncObject) { if (this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Enable || this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Active) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Disable; } new Thread(new ThreadStart(this.ExecuteDisable)) { Priority = this.Priority }.Start(); return(true); } }
protected virtual void Dispose(bool disposing) { if (this.disposed) { return; } if (disposing) { this.Remove = true; this.Ready = false; this.Error = false; this.disposed = true; this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Disposed; this.TerminateThread(); this.cyclicMrEvent.Reset(); } this.disposed = true; }
private void CallOnUpdateTick() { if (this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Active) { if (this.CallEvent(this.hdOnTick)) { return; } lock (this.syncObject) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Error; this.SetError(); } } else { if (this.tickerState != PhoenixContact.Common.Ticker.Ticker.TickerMode.Enable) { return; } if (this.CallEvent(this.hdOnEnable)) { lock (this.syncObject) { if (this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Disable) { return; } this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Active; this.Ready = true; } } else { lock (this.syncObject) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Error; this.SetError(); } } } }
public bool Disable() { lock (this.syncObject) { if (this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Active) { this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Disable; this.TerminateThread(); this.Ready = false; return(true); } if (this.tickerState == PhoenixContact.Common.Ticker.Ticker.TickerMode.Error) { this.TerminateThread(); this.Ready = false; this.Error = false; this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle; return(true); } } return(false); }