Ejemplo n.º 1
0
    static async Task Main()
    {
        await using var exampleAsyncDisposable = new ExampleAsyncDisposable();

        // Interact with the exampleAsyncDisposable instance.

        Console.ReadLine();
    }
Ejemplo n.º 2
0
    static async Task Main()
    {
        var exampleAsyncDisposable = new ExampleAsyncDisposable();

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

        Console.ReadLine();
    }
Ejemplo n.º 3
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();
    }
Ejemplo n.º 4
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();
    }
Ejemplo n.º 5
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();
    }