5#include <system/object.h>
6#include <system/collections/ienumerable.h>
7#include <system/threading/tasks/task.h>
8#include <system/threading/tasks/result_task.h>
9#include <system/threading/tasks/async.h>
10#include <system/array.h>
12namespace System {
namespace Threading {
14class CancellationToken;
51template<
typename TResult>
54 return MakeAsync<TResult>([=](System::Details::ResultAsyncContext<TResult>& __context) { exception.Throw(); });
72template <
typename TResult>
75 return MakeAsync<TResult>([=](System::Details::ResultAsyncContext<TResult>& __context) { __context.Return(result); });
81template <
typename TResult>
84 auto result = MakeObject<ResultTask<TResult>>(function);
117 return WhenAll(tasks->LINQ_ToArray());
147 return MakeAsync<ArrayPtr<T>>([=](System::Details::ResultAsyncContext<ArrayPtr<T>>& __context)
149 for (
auto& task : tasks)
151 if (!task->get_IsCompleted())
157 auto size = tasks->get_Length();
158 auto result = MakeArray<T>(size);
159 for (
auto i = 0; i < size; ++ i)
161 result[i] = tasks[i]->get_Result();
163 __context.Return(result);
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:25
Template that represents wrapper of exceptions that are derived from Exception class.
Definition: exception.h:113
Function delegate. This type should be allocated on stack and passed to functions by value or by refe...
Definition: func.h:82
Propagates notification that operations should be canceled. This class provides a mechanism for coope...
Definition: cancellation_token.h:43
void Start()
Starts the task execution using the default scheduler.
TaskPtr Delay(int32_t millisecondsDelay)
Creates a task that completes after a time delay.
TaskPtr WhenAll(const ArrayPtr< TaskPtr > &tasks)
TaskPtr Run(const Action<> &action)
TaskPtr FromException(const Exception &exception)
RTaskPtr< TResult > FromResult(TResult result)
Definition: task_utils.h:73
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40