Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 private void ExecuteDisable()
 {
     lock (this.syncObject)
     {
         this.TerminateThread();
         this.Ready       = false;
         this.Error       = false;
         this.tickerState = PhoenixContact.Common.Ticker.Ticker.TickerMode.Idle;
     }
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 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();
             }
         }
     }
 }
Ejemplo n.º 8
0
 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);
 }