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

使用系統提供的錯誤訊息,初始化 OperationCanceledException 類別的新執行個體。

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

備註

這個建構函式會將 Message 新實例的 屬性初始化為系統提供的訊息,描述錯誤,例如「作業已取消」。此訊息會將目前的系統文化特性納入考慮。

下表顯示 OperationCanceledException 執行個體的初始屬性值。

屬性
InnerException Visual Basic) Nothing 中的 nullreference (。
Message 當地語系化的錯誤訊息字串。
CancellationToken 以非取消狀態建立的取消權杖。

另請參閱

適用於

OperationCanceledException(String)

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

描述錯誤的 String

備註

message 的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

下表顯示 OperationCanceledException 執行個體的初始屬性值。

屬性
InnerException null 參考 (在 Visual Basic 中為 Nothing)。
Message 錯誤訊息字串。
CancellationToken 以非取消狀態建立的取消權杖。

另請參閱

適用於

OperationCanceledException(CancellationToken)

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 Visual Basic) Nothing 中的 nullreference (。
Message 當地語系化的錯誤訊息字串。
CancellationToken token.

另請參閱

適用於

OperationCanceledException(SerializationInfo, StreamingContext)

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);
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);
new OperationCanceledException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> OperationCanceledException
[<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
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

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 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

做為目前例外狀況發生原因的例外狀況。 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。

備註

message 的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

被擲回以做為前一個例外狀況直接結果的例外狀況,應該在 InnerException 屬性中包含對前一個例外狀況的參考。 InnerException 屬性傳回的值會與傳入建構函式的值相同,或傳回 null (如果 InnerException 屬性未提供內部例外狀況值給建構函式)。

下表顯示 OperationCanceledException 執行個體的初始屬性值。

屬性類型 條件
InnerException innerException.
Message message.
CancellationToken 以非取消狀態建立的取消權杖。

另請參閱

適用於

OperationCanceledException(String, CancellationToken)

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 參考 (在 Visual Basic 中為 Nothing)。
Message message.
CancellationToken token.

另請參閱

適用於

OperationCanceledException(String, Exception, CancellationToken)

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

做為目前例外狀況發生原因的例外狀況。 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。

token
CancellationToken

與已取消的作業相關聯的取消語彙基元。

備註

message 的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

被擲回以做為前一個例外狀況直接結果的例外狀況,應該在 InnerException 屬性中包含對前一個例外狀況的參考。 InnerException 屬性傳回的值會與傳入建構函式的值相同,或傳回 null (如果 InnerException 屬性未提供內部例外狀況值給建構函式)。

下表顯示 OperationCanceledException 執行個體的初始屬性值。

屬性類型 條件
InnerException innerException.
Message message.
CancellationToken token.

另請參閱

適用於