public ActorTask(Task task) { Debug.Assert(_currentCanceller != null); Task = task; Traits = _currentActorTaskTraits; _canceller = _currentCanceller; _currentCanceller = null; _currentActorTaskTraits = ActorTaskTraits.None; }
internal async Task ShouldBeAbleToResumeInitiallyPausedScheduler(ActorTaskTraits resumingTaskTraits) { var count = 0; var task1 = _actorTaskFactory.StartNew(() => ++ count, CancellationToken.None, TaskCreationOptions.None, ActorTaskTraits.None); var task2 = _actorTaskFactory.StartNew(() => ++ count, CancellationToken.None, TaskCreationOptions.None, ActorTaskTraits.None); Task.WhenAny(task1, task2).Wait(TimeSpan.FromSeconds(1)).Should().BeFalse("tasks should not have been executed if the scheduler is paused"); var resumer = _actorTaskFactory.StartNew(() => ++ count, CancellationToken.None, TaskCreationOptions.None, resumingTaskTraits); (await resumer).Should().Be(1); (await task1).Should().Be(2); (await task2).Should().Be(3); }
public ActorSynchronizationContext ChangeActorTaskKind(ActorTaskTraits actorTaskTraits) => new ActorSynchronizationContext(_actorTaskFactory, actorTaskTraits);
public ActorSynchronizationContext(ActorTaskFactory actorTaskFactory, ActorTaskTraits actorTaskTraits) { _actorTaskFactory = actorTaskFactory; _actorTaskTraits = actorTaskTraits; }