Beispiel #1
0
        private void OnTaskRunMessage(TaskRunMessage taskRunMessage)
        {
            var context = new MessageHandleContext {
                Self = Self, Sender = base.Sender, CancellationToken = CancellationToken
            };

            if (taskRunMessage.IsReentrant)
            {
                _activeReentrantCount += 1;
            }
            else
            {
                BecomeStacked(OnReceiveInAtomicTask);
                _currentAtomicContext = context;
            }

            using (new SynchronizationContextSwitcher(new ActorSynchronizationContext(context)))
            {
                taskRunMessage.Function()
                .ContinueWith(t => OnTaskCompleted(t.Exception, taskRunMessage.IsReentrant),
                              TaskContinuationOptions.ExecuteSynchronously);
            }
        }