コード例 #1
0
    static async Task Main()
    {
        await using var exampleAsyncDisposable = new ExampleAsyncDisposable();

        // Interact with the exampleAsyncDisposable instance.

        Console.ReadLine();
    }
コード例 #2
0
ファイル: proper-await-using.cs プロジェクト: wzchua/docs
    static async Task Main()
    {
        var exampleAsyncDisposable = new ExampleAsyncDisposable();

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

        Console.ReadLine();
    }
コード例 #3
0
ファイル: stacked-await-usings.cs プロジェクト: tola/docs
    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();
    }
コード例 #4
0
ファイル: stacked-await-usings.cs プロジェクト: tola/docs
    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();
    }
コード例 #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();
    }