7#include <system/object.h>
8#include <system/collections/ienumerable.h>
9#include <system/linq/enumerable.h>
10#include <system/threading/tasks/task.h>
11#include <system/threading/tasks/result_task.h>
12#include <system/threading/tasks/async.h>
13#include <system/array.h>
19namespace Runtime {
namespace CompilerServices {
44 static constexpr bool continueOnCapturedContext =
false;
59class CancellationToken;
90template<
typename TResult>
93 return MakeAsync<TResult>([=](System::Details::ResultAsyncContext<TResult>& __context) { exception.Throw(); });
100template <
typename TResult>
103 return MakeObject<ResultTask<TResult>>(result);
126template <
typename TResult>
129 auto result = MakeObject<ResultTask<TResult>>(function);
170template <
typename TResult>
173 return WhenAll(tasks->LINQ_ToArray());
180template <
typename TResult>
183 auto size = tasks->get_Length();
192 auto result = task->get_Result();
194 return MakeArray<TResult>({result});
199 auto result = MakeArray<TResult>(size);
200 for (
auto i = 0; i < size; ++i)
202 result[i] = tasks_copy[i]->get_Result();
204 tasks_copy =
nullptr;
223template <
typename TResult>
228 return ExplicitCast<ResultTask<TResult>>(task->get_Result());
236template <
typename TResult>
239 return WhenAny(tasks->LINQ_ToArray());
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
The awaiter type for YieldAwaitable.
Definition: task_utils.h:30
void OnCompleted(const Action<> &continuation)
Schedules the continuation action for when the yield operation completes.
bool get_IsCompleted() const
Gets whether the yield operation has completed.
Definition: task_utils.h:34
void GetResult() const
Ends the await operation.
Definition: task_utils.h:41
An awaitable type that is returned from TaskUtils::Yield().
Definition: task_utils.h:25
YieldAwaiter GetAwaiter() const
Gets the awaiter for this awaitable.
Definition: task_utils.h:49
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 ContinueWith(const Action< TaskPtr > &continuationAction)
Creates a continuation that executes when the task completes.
void WaitAll(const ArrayPtr< TaskPtr > &tasks, const CancellationToken &cancellationToken)
Waits for all of the provided Task objects to complete execution.
int32_t WaitAny(const ArrayPtr< TaskPtr > &tasks, const CancellationToken &cancellationToken)
Waits for any of the provided Task objects to complete execution.
TaskPtr Delay(int32_t millisecondsDelay)
Creates a task that completes after a time delay.
TaskPtr WhenAll(const ArrayPtr< TaskPtr > &tasks)
Creates a task that will complete when all of the supplied tasks have completed.
TaskPtr Run(const Action<> &action)
Queues the specified work to run on the thread pool and returns a Task handle for that work.
TaskPtr FromException(const Exception &exception)
Creates a task that has completed with a specified exception.
RTaskPtr< TResult > FromResult(TResult result)
Creates a task that has successfully completed with the specified result.
Definition: task_utils.h:101
RTaskPtr< TaskPtr > WhenAny(const SharedPtr< Collections::Generic::IEnumerable< TaskPtr > > &tasks)
Creates a task that will complete when any of the supplied tasks have completed.
Runtime::CompilerServices::YieldAwaitable Yield()
Creates an awaitable task that asynchronously yields back to the current context when awaited.
TaskPtr FromCanceled(const CancellationToken &cancellationToken)
Creates a task that has completed due to cancellation with the specified token.
Definition: db_command.h:9
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40