Exemple #1
0
    static async Task Main()
    {
        var exampleAsyncDisposable = new ExampleAsyncDisposable();

        await using (exampleAsyncDisposable.ConfigureAwait(false))
        {
            // Interact with the exampleAsyncDisposable instance.
        }

        Console.ReadLine();
    }
Exemple #2
0
    static async Task Main()
    {
        var objOne = new ExampleAsyncDisposable();
        // Exception thrown on .ctor
        var objTwo = new AnotherAsyncDisposable();

        await using (objOne.ConfigureAwait(false))
            await using (objTwo.ConfigureAwait(false))
            {
                // Only objOne has its DisposeAsync called.
            }

        Console.ReadLine();
    }
Exemple #3
0
    static async Task Main()
    {
        var objOne = new ExampleAsyncDisposable();

        await using var ignored1 = objOne.ConfigureAwait(false);

        var objTwo = new ExampleAsyncDisposable();

        await using var ignored2 = objTwo.ConfigureAwait(false);

        // Interact with objOne and/or objTwo instance(s).

        Console.ReadLine();
    }
Exemple #4
0
    static async Task Main()
    {
        var objOne = new ExampleAsyncDisposable();
        await using objOne.ConfigureAwait(false);
        // Interact with the objOne instance.

        var objTwo = new ExampleAsyncDisposable();
        await using objTwo.ConfigureAwait(false))
        {
            // Interact with the objTwo instance.
        }

        Console.ReadLine();
    }