Beispiel #1
0
        public void Stop()
        {
            ChoGuard.NotDisposed(this);

            _waitHandle.Set();
            Thread.Sleep(100);
            if (_idleThread.IsAlive)
            {
                _idleThread.AbortThread();
            }
        }
Beispiel #2
0
 public void Abort()
 {
     AbortRequested = true;
     if (_threadToKill != null && _threadToKill.IsAlive)
     {
         _threadToKill.AbortThread();
         SetAsAborted(true);
     }
 }
 public void Abort()
 {
     if (_threadToKill != null)
     {
         if ((_threadToKill.ThreadState & (ThreadState.Aborted | ThreadState.Stopped)) == 0)
         {
             _threadToKill.AbortThread();
         }
     }
 }
        public void Abort()
        {
            if (ChoApplication.ApplicationMode != ChoApplicationMode.Console)
            {
                return;
            }

            if (_threadToKill != null)
            {
                if ((_threadToKill.ThreadState & (ThreadState.Aborted | ThreadState.Stopped)) == 0)
                {
                    _threadToKill.AbortThread();
                }
            }
        }
Beispiel #5
0
        private void Stop(bool silent)
        {
            if (ChoGuard.IsDisposed(this))
            {
                return;
            }

            _stoppingService = true;

            //if (!silent)
            //    CheckState();

            lock (_padLock)
            {
                if (_queueProcessingThread != null || _queue.Count > 0)
                {
                    //_queue.Enqueue(0, _shutdownMsg);
                    _queue.Enqueue(_shutdownMsg);
                    int noOfRetry = 0;
                    while (true)
                    {
                        //Enqueue(_endOfMsg);
                        if (ChoTraceSwitch.Switch.TraceVerbose)
                        {
                            Trace.WriteLine("{0}: Stopping thread...".FormatString(_name));
                        }

                        if (_queueProcessingThread == null || !_queueProcessingThread.IsAlive || _queueProcessingThread.Join(1000))
                        {
                            if (ChoTraceSwitch.Switch.TraceVerbose)
                            {
                                Trace.WriteLine("{0}: Stopped thread...".FormatString(_name));
                            }

                            _queueProcessingThread = null;
                            //_stoppingService = false;
                            break;
                        }
                        else
                        {
                            Thread.Sleep(10);
                        }

                        noOfRetry++;
                        if (noOfRetry >= 5)
                        {
                            Trace.WriteLine("{0}: Aborting thread...".FormatString(_name));

                            try
                            {
                                _queueProcessingThread.AbortThread();
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(ex.ToString());
                            }

                            break;
                        }
                    }
                    if (_queueProcessingThread != null /*&& !_queueProcessingThread.IsAlive */)
                    {
                        _queueProcessingThread = null;
                    }
                }
            }
        }