通过


TaskCanceledException 构造函数

定义

初始化 TaskCanceledException 类的新实例。

重载

名称 说明
TaskCanceledException()

使用描述错误的系统提供的消息初始化 TaskCanceledException 类的新实例。

TaskCanceledException(String)

使用描述错误的指定消息初始化 TaskCanceledException 类的新实例。

TaskCanceledException(Task)

使用对已取消的类的引用Task初始化类的新实例TaskCanceledException

TaskCanceledException(SerializationInfo, StreamingContext)
已过时.

使用序列化数据初始化类的新实例 TaskCanceledException

TaskCanceledException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用初始化类的新实例 TaskCanceledException

TaskCanceledException(String, Exception, CancellationToken)

使用指定的错误消息、对内部异常的引用、导致此异常的原因以及CancellationToken触发取消的异常初始化类的新实例TaskCanceledException

TaskCanceledException()

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

使用描述错误的系统提供的消息初始化 TaskCanceledException 类的新实例。

public:
 TaskCanceledException();
public TaskCanceledException();
Public Sub New ()

注解

此构造函数将 Message 新实例的属性初始化为描述错误的系统提供的消息。 此消息将考虑当前系统区域性。

下表显示了实例 OperationCanceledException的初始属性值:

财产 价值
InnerException null
Message 本地化的错误消息字符串。

另请参阅

适用于

TaskCanceledException(String)

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

使用描述错误的指定消息初始化 TaskCanceledException 类的新实例。

public:
 TaskCanceledException(System::String ^ message);
public TaskCanceledException(string message);
public TaskCanceledException(string? message);
new System.Threading.Tasks.TaskCanceledException : string -> System.Threading.Tasks.TaskCanceledException
Public Sub New (message As String)

参数

message
String

描述异常的消息。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

注解

下表显示了 TaskCanceledException实例的初始属性值。

财产 价值
InnerException null
Message message中指定的错误消息字符串。

另请参阅

适用于

TaskCanceledException(Task)

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

使用对已取消的类的引用Task初始化类的新实例TaskCanceledException

public:
 TaskCanceledException(System::Threading::Tasks::Task ^ task);
public TaskCanceledException(System.Threading.Tasks.Task task);
public TaskCanceledException(System.Threading.Tasks.Task? task);
new System.Threading.Tasks.TaskCanceledException : System.Threading.Tasks.Task -> System.Threading.Tasks.TaskCanceledException
Public Sub New (task As Task)

参数

task
Task

已取消的任务。

另请参阅

适用于

TaskCanceledException(SerializationInfo, StreamingContext)

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

注意

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

使用序列化数据初始化类的新实例 TaskCanceledException

protected:
 TaskCanceledException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected TaskCanceledException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected TaskCanceledException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Threading.Tasks.TaskCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Threading.Tasks.TaskCanceledException
new System.Threading.Tasks.TaskCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Threading.Tasks.TaskCanceledException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

保存序列化对象数据的对象。

context
StreamingContext

有关源或目标的上下文信息。

属性

注解

在反序列化期间调用此构造函数以重新构造通过流传输的异常对象。 有关详细信息,请参阅 XML 和 SOAP 序列化

另请参阅

适用于

TaskCanceledException(String, Exception)

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

使用指定的错误消息和对作为此异常原因的内部异常的引用初始化类的新实例 TaskCanceledException

public:
 TaskCanceledException(System::String ^ message, Exception ^ innerException);
public TaskCanceledException(string message, Exception innerException);
public TaskCanceledException(string? message, Exception? innerException);
new System.Threading.Tasks.TaskCanceledException : string * Exception -> System.Threading.Tasks.TaskCanceledException
Public Sub New (message As String, innerException As Exception)

参数

message
String

描述异常的消息。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

innerException
Exception

是当前异常原因的异常。 如果未 innerExceptionnull 参数,则会在处理内部异常的 catch 块中引发当前异常。

注解

作为上一个异常的直接结果引发的异常应包括对 InnerException 属性中上一个异常的引用。 InnerException 属性返回传入构造函数的相同值,或者如果 null 属性未向构造函数提供内部异常值,则返回 InnerException

下表显示了 TaskCanceledException实例的初始属性值。

财产 价值
InnerException null
Message message中指定的错误消息字符串。

另请参阅

适用于

TaskCanceledException(String, Exception, CancellationToken)

Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs
Source:
TaskCanceledException.cs

使用指定的错误消息、对内部异常的引用、导致此异常的原因以及CancellationToken触发取消的异常初始化类的新实例TaskCanceledException

public:
 TaskCanceledException(System::String ^ message, Exception ^ innerException, System::Threading::CancellationToken token);
public TaskCanceledException(string? message, Exception? innerException, System.Threading.CancellationToken token);
public TaskCanceledException(string message, Exception innerException, System.Threading.CancellationToken token);
new System.Threading.Tasks.TaskCanceledException : string * Exception * System.Threading.CancellationToken -> System.Threading.Tasks.TaskCanceledException
Public Sub New (message As String, innerException As Exception, token As CancellationToken)

参数

message
String

说明异常原因的错误消息。

innerException
Exception

是当前异常原因的异常。

token
CancellationToken

触发取消的取消令牌。

适用于