Esempio n. 1
0
        internal override async Task CreateNewTaskExecutor(CancellationToken token)
        {
            IncrementExecutorCounter();
            try
            {
                TaskSubscriber <T> subscriber = null;
                try
                {
                    subscriber = ExecutorActivator();
                }
                catch (Exception e)
                {
                    ExecutorActivationException?.Invoke(this, e);
                    return;
                }
                LinkNewExecutor(subscriber);
                SubscriberExecutionStarting?.Invoke(subscriber);
                await subscriber.StartSubscribe().ConfigureAwait(false);

                SubscriberFinalized?.Invoke(subscriber);
                subscriber?.Dispose();
            }
            catch (Exception e)
            {
                SubscriberExecutionException?.Invoke(this, e);
            }
            finally
            {
                DecrementExecutorCounter();
            }
        }
Esempio n. 2
0
        private void LinkNewExecutor(TaskSubscriber <T> subscriber)
        {
            subscriber.LinkedMetadata = this;
            var cts = new CancellationTokenSource();

            InstanceCancelEvent.WaitAsync().ContinueWith(t => cts.Cancel(), CancellationToken.None);
            subscriber.TaskManagerCancellationToken =
                CancellationTokenSource.CreateLinkedTokenSource(TaskManagerCancellationToken.Token, cts.Token);
        }