OperationCanceledException 构造函数

定义

初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class.

重载

OperationCanceledException()

使用系统提供的错误信息初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a system-supplied error message.

OperationCanceledException(String)

用指定的错误消息初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message.

OperationCanceledException(CancellationToken)

用取消令牌初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a cancellation token.

OperationCanceledException(SerializationInfo, StreamingContext)

用序列化数据初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with serialized data.

OperationCanceledException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message and a reference to the inner exception that is the cause of this exception.

OperationCanceledException(String, CancellationToken)

使用指定的错误信息和取消令牌初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message and a cancellation token.

OperationCanceledException(String, Exception, CancellationToken)

使用指定的错误消息、对作为此异常原因的内部异常的引用以及取消标记来初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message, a reference to the inner exception that is the cause of this exception, and a cancellation token.

OperationCanceledException()

使用系统提供的错误信息初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a system-supplied error message.

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

注解

此构造函数将 Message 新实例的属性初始化为系统提供的描述错误的消息,如 "该操作已取消"。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "The operation was canceled." 此消息会考虑当前系统区域性。This message takes into account the current system culture.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

propertiesProperty ValueValue
InnerException NothingVisual Basic) 中的 nullreferernce (。A nullreference (Nothing in Visual Basic).
Message 本地化的错误消息字符串。The localized error message string.
CancellationToken 在非取消状态中创建的取消标记。A cancellation token created in the non-canceled state.

另请参阅

OperationCanceledException(String)

用指定的错误消息初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message.

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

参数

message
String

描述该错误的 StringA String that describes the error.

注解

message 的内容设计为易于理解。The content of message is intended to be understood by humans. 此构造函数的调用方需要确保此字符串已针对当前系统区域性进行了本地化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

propertiesProperty Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message 错误消息字符串。The error message string.
CancellationToken 在非取消状态中创建的取消标记。A cancellation token created in the non-canceled state.

另请参阅

OperationCanceledException(CancellationToken)

用取消令牌初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a cancellation token.

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

与已取消的操作关联的取消标记。A cancellation token associated with the operation that was canceled.

注解

此构造函数将 Message 新实例的属性初始化为系统提供的描述错误的消息,如 "该操作已取消"。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "The operation was canceled." 此消息会考虑当前系统区域性。This message takes into account the current system culture.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

propertiesProperty ValueValue
InnerException NothingVisual Basic) 中的 nullreferernce (。A nullreference (Nothing in Visual Basic).
Message 本地化的错误消息字符串。The localized error message string.
CancellationToken token.token.

另请参阅

OperationCanceledException(SerializationInfo, StreamingContext)

用序列化数据初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with serialized data.

protected:
 OperationCanceledException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected OperationCanceledException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new OperationCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> OperationCanceledException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

承载序列化对象数据的对象。The object that holds the serialized object data.

context
StreamingContext

关于来源和目标的上下文信息The contextual information about the source or destination.

注解

在反序列化期间调用此构造函数以重新构造在流上传输的异常对象。This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. 有关详细信息,请参阅 XML 和 SOAP 序列化For more information, see XML and SOAP Serialization

另请参阅

OperationCanceledException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 OperationCanceledException(System::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

解释异常原因的错误消息。The error message that explains the reason for the exception.

innerException
Exception

导致当前异常的异常。The exception that is the cause of the current exception. 如果 innerException 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

注解

message 的内容设计为易于理解。The content of message is intended to be understood by humans. 此构造函数的调用方需要确保此字符串已针对当前系统区域性进行了本地化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

因前一个异常而直接引发的异常应在 InnerException 属性中包含对前一个异常的引用。An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. InnerException 属性将返回传递给构造函数的同一值;如果 InnerException 属性不向构造函数提供内部异常值,则返回 nullThe InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

属性类型Property Type 条件Condition
InnerException innerException.innerException.
Message message.message.
CancellationToken 在非取消状态中创建的取消标记。A cancellation token created in the non-canceled state.

另请参阅

OperationCanceledException(String, CancellationToken)

使用指定的错误信息和取消令牌初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message and a cancellation token.

public:
 OperationCanceledException(System::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

解释异常原因的错误消息。The error message that explains the reason for the exception.

token
CancellationToken

与已取消的操作关联的取消标记。A cancellation token associated with the operation that was canceled.

注解

message 的内容设计为易于理解。The content of message is intended to be understood by humans. 此构造函数的调用方需要确保此字符串已针对当前系统区域性进行了本地化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

propertiesProperty Value
InnerException 空引用(在 Visual Basic 中为 Nothing)。A null reference (Nothing in Visual Basic).
Message message.message.
CancellationToken token.token.

另请参阅

OperationCanceledException(String, Exception, CancellationToken)

使用指定的错误消息、对作为此异常原因的内部异常的引用以及取消标记来初始化 OperationCanceledException 类的新实例。Initializes a new instance of the OperationCanceledException class with a specified error message, a reference to the inner exception that is the cause of this exception, and a cancellation token.

public:
 OperationCanceledException(System::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

解释异常原因的错误消息。The error message that explains the reason for the exception.

innerException
Exception

导致当前异常的异常。The exception that is the cause of the current exception. 如果 innerException 参数不为 null,则当前异常将在处理内部异常的 catch 块中引发。If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

token
CancellationToken

与已取消的操作关联的取消标记。A cancellation token associated with the operation that was canceled.

注解

message 的内容设计为易于理解。The content of message is intended to be understood by humans. 此构造函数的调用方需要确保此字符串已针对当前系统区域性进行了本地化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

因前一个异常而直接引发的异常应在 InnerException 属性中包含对前一个异常的引用。An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. InnerException 属性将返回传递给构造函数的同一值;如果 InnerException 属性不向构造函数提供内部异常值,则返回 nullThe InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

下表显示了 OperationCanceledException 实例的初始属性值。The following table shows the initial property values for an instance of OperationCanceledException.

属性类型Property Type 条件Condition
InnerException innerException.innerException.
Message message.message.
CancellationToken token.token.

另请参阅

适用于