Table of Contents

Class AsyncDisposableOptions

Namespace
Cuemon.IO
Assembly
Cuemon.IO.dll

Configuration options for IDisposable.

public class AsyncDisposableOptions : AsyncOptions, IAsyncOptions, IParameterObject
Inheritance
AsyncDisposableOptions
Implements
Derived
Inherited Members

Examples

The following example demonstrates how to configure AsyncDisposableOptions to control whether a disposable resource is left open after an async operation.

using System;
using System.IO;
using System.Threading.Tasks;
using Cuemon.IO;

namespace MyApp.Examples;

public class AsyncDisposableOptionsExample
{
    public static async Task Main()
    {
        var options = new AsyncDisposableOptions
        {
            LeaveOpen = true
        };

        var stream = new MemoryStream();
        // Use options.LeaveOpen to decide disposal behavior
        if (!options.LeaveOpen)
        {
            stream.Dispose();

        Console.WriteLine("LeaveOpen: {0}", options.LeaveOpen);
        Console.WriteLine("Stream still open: {0}", stream.CanWrite);

        // Output:
        // LeaveOpen: True
        // Stream still open: True

}}
}

Constructors

AsyncDisposableOptions()

Initializes a new instance of the AsyncDisposableOptions class.

public AsyncDisposableOptions()

Remarks

The following table shows the initial property values for an instance of AsyncDisposableOptions.

PropertyInitial Value
LeaveOpenfalse

Properties

LeaveOpen

Gets or sets a value indicating whether a disposable object should bypass the mechanism for releasing unmanaged resources. Default is false.

public bool LeaveOpen { get; set; }

Property Value

bool

true if a disposable object should bypass the mechanism for releasing unmanaged resources; otherwise, false.