Exemplo n.º 1
0
        public static AsyncTask Create(string name, Action <AsyncTaskControl> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var taskCompletionSource = new TaskCompletionSource <Unit>();
            var task      = taskCompletionSource.Task;
            var namedTask = new NamedTask(string.IsNullOrEmpty(name) ? "Task#" + task.Id : name, task);
            var control   = new AsyncTaskControl(namedTask, taskCompletionSource);

            return(new AsyncTask(namedTask, new Task(() => action(control), TaskCreationOptions.DenyChildAttach)));
        }
Exemplo n.º 2
0
 AsyncTask(NamedTask task, Task inner)
 {
     _task  = task;
     _inner = inner;
 }
Exemplo n.º 3
0
 public AsyncTaskControl(NamedTask task, TaskCompletionSource <Unit> completionSource)
 {
     Task = task;
     _completionSource = completionSource ?? throw new ArgumentNullException(nameof(completionSource));
 }