通过


OperationCanceledException 构造函数

定义

初始化 OperationCanceledException 类的新实例。

重载

名称 说明
OperationCanceledException()

使用系统提供的错误消息初始化类的新实例 OperationCanceledException

OperationCanceledException(String)

使用指定的错误消息初始化类的新实例 OperationCanceledException

OperationCanceledException(CancellationToken)

使用取消标记初始化类的新实例 OperationCanceledException

OperationCanceledException(SerializationInfo, StreamingContext)
已过时.

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

OperationCanceledException(String, Exception)

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

OperationCanceledException(String, CancellationToken)

使用指定的错误消息和取消令牌初始化类的新实例 OperationCanceledException

OperationCanceledException(String, Exception, CancellationToken)

使用指定的错误消息、对作为此异常原因的内部异常的引用以及取消令牌初始化类的新实例 OperationCanceledException

OperationCanceledException()

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

使用系统提供的错误消息初始化类的新实例 OperationCanceledException

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

注解

此构造函数将 Message 新实例的属性初始化为系统提供的消息,该消息描述错误,例如“操作已取消”。此消息将考虑当前系统区域性。

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

财产 价值
InnerException nullreference (Nothing 在 Visual Basic 中)。
Message 本地化的错误消息字符串。
CancellationToken 在未取消状态下创建的取消令牌。

另请参阅

适用于

OperationCanceledException(String)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

使用指定的错误消息初始化类的新实例 OperationCanceledException

public:
 OperationCanceledException(System::String ^ message);
public OperationCanceledException(string message);
public OperationCanceledException(string? message);
new OperationCanceledException : string -> OperationCanceledException
Public Sub New (message As String)

参数

message
String

描述错误的 A String

注解

内容 message 旨在由人类理解。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

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

财产 价值
InnerException Null 引用(Nothing 在 Visual Basic 中)。
Message 错误消息字符串。
CancellationToken 在未取消状态下创建的取消令牌。

另请参阅

适用于

OperationCanceledException(CancellationToken)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

使用取消标记初始化类的新实例 OperationCanceledException

public:
 OperationCanceledException(System::Threading::CancellationToken token);
public OperationCanceledException(System.Threading.CancellationToken token);
new OperationCanceledException : System.Threading.CancellationToken -> OperationCanceledException
Public Sub New (token As CancellationToken)

参数

token
CancellationToken

与取消的操作关联的取消令牌。

注解

此构造函数将 Message 新实例的属性初始化为系统提供的消息,该消息描述错误,例如“操作已取消”。此消息将考虑当前系统区域性。

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

财产 价值
InnerException nullreference (Nothing 在 Visual Basic 中)。
Message 本地化的错误消息字符串。
CancellationToken token

另请参阅

适用于

OperationCanceledException(SerializationInfo, StreamingContext)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

注意

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

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

protected:
 OperationCanceledException(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 OperationCanceledException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected OperationCanceledException(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 OperationCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> OperationCanceledException
new OperationCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> OperationCanceledException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

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

context
StreamingContext

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

属性

注解

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

另请参阅

适用于

OperationCanceledException(String, Exception)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

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

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

参数

message
String

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

innerException
Exception

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

注解

内容 message 旨在由人类理解。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

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

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

属性类型 条件
InnerException innerException
Message message
CancellationToken 在未取消状态下创建的取消令牌。

另请参阅

适用于

OperationCanceledException(String, CancellationToken)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

使用指定的错误消息和取消令牌初始化类的新实例 OperationCanceledException

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

参数

message
String

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

token
CancellationToken

与取消的操作关联的取消令牌。

注解

内容 message 旨在由人类理解。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

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

财产 价值
InnerException Null 引用(Nothing 在 Visual Basic 中)。
Message message
CancellationToken token

另请参阅

适用于

OperationCanceledException(String, Exception, CancellationToken)

Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs
Source:
OperationCanceledException.cs

使用指定的错误消息、对作为此异常原因的内部异常的引用以及取消令牌初始化类的新实例 OperationCanceledException

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

参数

message
String

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

innerException
Exception

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

token
CancellationToken

与取消的操作关联的取消令牌。

注解

内容 message 旨在由人类理解。 此构造函数的调用方必须确保此字符串已本地化为当前系统区域性。

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

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

属性类型 条件
InnerException innerException
Message message
CancellationToken token

另请参阅

适用于