示例#1
0
        /// <summary>
        /// Stops the scanning process
        /// </summary>
        /// <returns></returns>
        public async Task StopAsync()
        {
            await Task.Run(() =>
            {
                OnCanceling?.Invoke(this, new EventArgs {
                });

                ScanCancellationTokenSource.Cancel();

                Task.WhenAll(Workers.Select(w => w.Task)).ContinueWith((t) =>
                {
                    OnCanceled?.Invoke(this, new EventArgs {
                    });
                }).Wait();
            });
        }
示例#2
0
        protected override void OnStop()
        {
            OnCanceling?.Invoke();

            base.OnStop();
        }