Beispiel #1
0
        protected async override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            this._tasks = new TaskInfoCollection();
            this._stop  = stoppingToken;

            Thread fetch = new Thread(this.FetchThread);

            fetch.Start();

            Thread[] dispatches = new Thread[this._workers];
            for (int i = 0; i < this._workers; i++)
            {
                Thread dispatch = new Thread(this.DispatchThread);
                dispatch.Start();
                dispatches[i] = dispatch;
            }

            await stoppingToken.WaitHandle.WaitOneAsync();

            fetch.Join();
            foreach (var d in dispatches)
            {
                d.Join();
            }
        }
Beispiel #2
0
 public DispatchWorker(TaskInfoCollection tasks)
 {
     this._tasks = tasks;
 }