TaskCanceledException 建構函式

定義

初始化 TaskCanceledException 類別的新執行個體。

多載

TaskCanceledException()

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

TaskCanceledException(String)

初始化具有指定的錯誤描述訊息之 TaskCanceledException 類別的新執行個體。

TaskCanceledException(Task)

使用已取消之 TaskCanceledException 的參考,初始化 Task 類別的新執行個體。

TaskCanceledException(SerializationInfo, StreamingContext)
已淘汰.

使用序列化資料,初始化 TaskCanceledException 類別的新執行個體。

TaskCanceledException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 TaskCanceledException 類別的新執行個體。

TaskCanceledException(String, Exception, CancellationToken)

使用指定的錯誤訊息、造成此例外狀況的內部例外狀況參考,以及觸發取消的 TaskCanceledException 來初始化 CancellationToken 類別的新執行個體。

TaskCanceledException()

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

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

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

備註

這個建構函式 (Constructor) 會將新執行個體的 Message 屬性初始化為系統提供用來描述錯誤的訊息。 此訊息會考慮到目前系統的文化特性。

下表顯示 實例 OperationCanceledException 的初始屬性值:

屬性
InnerException null.
Message 當地語系化的錯誤訊息字串。

另請參閱

適用於

TaskCanceledException(String)

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

使用已取消之 TaskCanceledException 的參考,初始化 Task 類別的新執行個體。

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

警告

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

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

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

備註

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

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

屬性
InnerException null.
Message message 中指定的錯誤訊息字串。

另請參閱

適用於

TaskCanceledException(String, Exception, CancellationToken)

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

使用指定的錯誤訊息、造成此例外狀況的內部例外狀況參考,以及觸發取消的 TaskCanceledException 來初始化 CancellationToken 類別的新執行個體。

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

觸發取消的取消權杖。

適用於