XmlWriter.WriteProcessingInstructionAsync(String, String) 方法

定義

以非同步方式寫出名稱與文字之間有空白的處理指示,如下所示:<?name text?>。Asynchronously writes out a processing instruction with a space between the name and text as follows: <?name text?>.

public:
 virtual System::Threading::Tasks::Task ^ WriteProcessingInstructionAsync(System::String ^ name, System::String ^ text);
public virtual System.Threading.Tasks.Task WriteProcessingInstructionAsync (string name, string text);
public virtual System.Threading.Tasks.Task WriteProcessingInstructionAsync (string name, string? text);
abstract member WriteProcessingInstructionAsync : string * string -> System.Threading.Tasks.Task
override this.WriteProcessingInstructionAsync : string * string -> System.Threading.Tasks.Task
Public Overridable Function WriteProcessingInstructionAsync (name As String, text As String) As Task

參數

name
String

處理指示的名稱。The name of the processing instruction.

text
String

要包含在處理指示中的文字。The text to include in the processing instruction.

傳回

Task

表示非同步 WriteProcessingInstruction 作業的工作。The task that represents the asynchronous WriteProcessingInstruction operation.

例外狀況

在先前的非同步作業完成前呼叫了 XmlWriter 方法。An XmlWriter method was called before a previous asynchronous operation finished. 在此情況下,會擲回 InvalidOperationException 與「非同步作業已經在進行中」的訊息。In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

-或--or-

在未將 Async 旗標設為 true的情況下呼叫了 XmlWriter 非同步方法。An XmlWriter asynchronous method was called without setting the Async flag to true. 在此情況下,就會擲回 InvalidOperationException 並顯示訊息「如果您要使用非同步方法,請將 XmlWriterSettings.Async 設為 true」。In this case, InvalidOperationException is thrown with the message "Set XmlWriterSettings.Async to true if you want to use Async Methods."

備註

這是的非同步版本 WriteProcessingInstruction ,具有相同的功能。This is the asynchronous version of WriteProcessingInstruction, with the same functionality. 若要使用這個方法,您必須將 Async 旗標設為 trueTo use this method, you must set the Async flag to true.

適用於