Exemple #1
0
        public void Stop(int timeoutInMs)
        {
            if (theThread != null)
            {
                threadShouldStop = true;
                threadTrigger.Release();

                if (theStoppingDelegate != null)
                {
                    theStoppingDelegate.Invoke();
                }

                if (!threadEnd.Wait(timeoutInMs))
                {
                    theThread.Abort();
                }
            }
        }
Exemple #2
0
        private void StartThreadExecute()
        {
            int timeoutValue = threadTimeoutInMs;

            threadStart.Release();
            running = true;

            while (!threadShouldStop)
            {
                try
                {
                    theRuntimeDelegate.Invoke();

                    if (timeoutValue > 0)
                    {
                        threadTrigger.Wait(timeoutValue);
                    }
                    if (threadShouldStop)
                    {
                        break;
                    }
                }
                catch (ThreadAbortException ex)
                {
                    Thread.ResetAbort();
                    break;
                }
                catch (Exception)
                {
                    if (recoverable && !threadShouldStop)
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            threadEnd.Release();
            running = false;
        }
Exemple #3
0
 private void Start()
 {
     action.Invoke();
 }