Ejemplo n.º 1
0
        protected override void InternalWaitComplete(ref bool waitComplete, XTimeout tOut)
        {
            base.InternalWaitComplete(ref waitComplete, tOut);

            if (waitComplete && tOut.Keep())
            {
                while (_data.Count > 0 && tOut.Keep())
                {
                    Thread.Sleep(100);
                }
            }

            waitComplete = false;

            _cancellationTokenSource.Cancel();
            _cancellationTokenSource = new CancellationTokenSource();
        }
Ejemplo n.º 2
0
        public async Task <bool> Stop(TimeSpan?timeout = null, bool waitComplete = false)
        {
            var tOut = new XTimeout(timeout ?? TimeSpan.Zero);

            lock (_syncRunning)
            {
                if (!_active || IsStopping)
                {
                    return(false);
                }

                _waitComplete = waitComplete;
                IsStopping    = true;
            }

            return(await Task.Run(() =>
            {
                InternalWaitComplete(ref _waitComplete, tOut);

                return tOut.WaitOne(_waitStop);
            }));
        }
Ejemplo n.º 3
0
 protected virtual void InternalWaitComplete(ref bool waitComplete, XTimeout tOut)
 {
 }