Table of Contents

AsyncEncodingOptions Class

Definition

Namespace
Cuemon.Text
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Text/AsyncEncodingOptions.cs

Specifies options that is related to the Encoding class.

public sealed class AsyncEncodingOptions : EncodingOptions, IEncodingOptions, IParameterObject, IAsyncOptions
Inheritance
AsyncEncodingOptions
Implements
Inherited Members

Examples

The following example demonstrates how to configure AsyncEncodingOptions with a cancellation token for use in asynchronous encoding operations.

// Program.cs
using System;
using System.Threading.Tasks;
using System.Text;
using System.Threading;
using Cuemon.Text;

using var cts = new CancellationTokenSource();
var options = new AsyncEncodingOptions
{
    Encoding = Encoding.UTF8,
    Preamble = PreambleSequence.Remove,
    CancellationToken = cts.Token
};

// The options can be passed to async encoding methods
// that accept AsyncEncodingOptions. If cancellation is
// requested, the operation will be cancelled gracefully.
Console.WriteLine(options.Encoding.WebName);
Console.WriteLine(options.Preamble);
Console.WriteLine(options.CancellationToken.CanBeCanceled);

Constructors

Name Description
AsyncEncodingOptions()

Initializes a new instance of the EncodingOptions class.

Properties

Name Description
CancellationToken

Gets or sets the cancellation token of an asynchronous operations.