共用方式為


RequestStart 事件

[Microsoft代理程式從 Windows 7 開始已被取代,而且可能無法在後續版本的 Windows 中使用。]

說明

當伺服器開始佇列要求時發生。

語法

代理程式**_RequestStart** (ByVal要求**)**

部分 描述
要求 回 Request 物件。

 

備註

事件會傳 回 Request 物件。 由於要求是以異步方式處理,因此您可以使用此事件來判斷伺服器何時開始處理要求(例如 GetPlay Speak 方法),並藉此將此動作與應用程式所產生的其他動作同步處理。 事件只會傳送至建立 Request 物件的參考的用戶端,而且只有在您為要求參考定義全域變數時:

   Dim MyRequest 
   Dim Genie 

   Sub window_Onload
   
   Agent1.Characters.Load "Genie", _
      "https://agent.microsoft.com/characters/v2/genie/genie.acf"   

   Set Genie = Agent1.Characters("Genie")

   ' This syntax will generate RequestStart and RequestComplete events.
   Set MyRequest = Genie.Get("state", "Showing")

   ' This syntax will not generate RequestStart and RequestComplete events.
   Genie.Get ("state", "Hiding")

   End Sub

   Sub Agent1_RequestStart(ByVal Request)

   If Request = MyRequest Then
      Status = "Loading the Showing animation"

   End Sub

Status針對傳回的要求物件傳回 4 (進行中要求)。

因為動畫 要求 對象在伺服器處理要求之前不會指派,所以在您嘗試評估要求之前,請先確定 Request 物件存在。 例如,在 Visual Basic 中,如果您使用條件來測試特定要求是否已完成,您可以使用 Nothing 關鍵詞:

   Sub Agent1_RequestStart (ByVal Request)

   If Not (MyRequest Is Nothing) Then
      If Request = MyRequest Then
      '-- Do whatever
      End If
   End If

   End Sub

注意

在 VBScript 1.0 中,即使您未定義 Request 對象的參考,也會引發此事件。 這已在 VBScript 2.0 中修正。

 

另請參閱

RequestComplete 事件