Esempio n. 1
0
        public void Stop()
        {
            if (ChoGuard.IsDisposed(this))
            {
                return;
            }

            lock (DisposableLockObj)
            {
                _isStopped = true;
            }
        }
Esempio n. 2
0
        public string AppendIf(bool condition, string msg)
        {
            ChoGuard.IsDisposed(this);

            if (!condition)
            {
                return(msg);
            }

            StartIfNotStarted();

            Write(msg, _indent + 1);

            return(msg);
        }
Esempio n. 3
0
        public void Stop()
        {
            if (ChoGuard.IsDisposed(this))
            {
                return;
            }

            lock (DisposableLockObj)
            {
                if (_timer != null)
                {
                    _timer.Dispose();
                    _timer = null;
                }
            }
        }
Esempio n. 4
0
        public override IChoAsyncResult EnqueueMethod(Delegate func, object[] parameters, ChoAsyncCallback callback, object state, int timeout, int maxNoOfRetry, int sleepBetweenRetry)
        {
            ChoGuard.ArgumentNotNull(func, "Function");
            CheckTimeoutArg(timeout);

            if (ChoGuard.IsDisposed(this))
            {
                return(null);
            }

            ChoExecutionServiceData data = new ChoExecutionServiceData(func, parameters, timeout, new ChoAsyncResult(callback, state), maxNoOfRetry, sleepBetweenRetry);

            _queuedMsgService.Enqueue(ChoStandardQueuedMsgObject <ChoExecutionServiceData> .New(data));

            return(data.Result);
        }
Esempio n. 5
0
        public string AppendLineIf(bool condition, string msg)
        {
            ChoGuard.IsDisposed(this);

            if (!condition)
            {
                return(msg);
            }
            if (msg == null)
            {
                return(AppendIf(condition, Environment.NewLine));
            }
            else
            {
                return(AppendIf(condition, msg + Environment.NewLine));
            }
        }
Esempio n. 6
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;
                    }
                }
            }
        }