Skip to content

Local async function in ctor #222

@JohanLarsson

Description

@JohanLarsson
    public sealed class Awaiter<T>
    {
        internal readonly Task<T> Task;

        internal Awaiter(Task<T> task)
        {
            this.Task = task;
            Await();

            async void Await()
            {
                try
                {
                    this.Value = await task.ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    this.Exception = e;
                }
            }
        }

        internal T? Value { get; private set; }

        internal Exception? Exception { get; private set; }
    }
    ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions