HTTP要求クラス - ExecuteAsyncメソッド

要求を非同期に実行

HttpRequestクラス (PRIM_WEB.HttpRequest) のメンバ

詳細

Execute メソッドは、 HTTPRequest を同期的に実行するために使用されます。 
リクエストが送信されると、処理は続行され、ユーザーのやりとりはブロックされません。
Asynchronous 要求よりも非同期要求の使用を推奨します。

この例では、 Weather API が非同期で実行され、データを JSON オブジェクトとして返します。
完了したイベントが発生すると、結果が処理されます。

     Mthroutine Name(GetWeather) Access(*Private)
Define_Map For(*Input) Class(#prim_alph) Name(#Resource)
        Define_Com Class(#PRIM_WEB.HttpRequest) Name(#Request) 
        #Request.URL := "http://api.openweathermap.org" + #Resource 
        #Request.ExecuteAsync 
        Evtroutine Handling(#Request.Completed) 
           If (#Request.Response *IsNot *null) 
           Case (#Request.Response.Status)
When (= 200)
              #Com_owner.Update( #Request.Response.JSON.RootItem ) 
           Otherwise 
              #Com_owner.UpdateForFailure( #Request ) 
           Endcase 
           Endif 
        Endroutine 
     Endroutine

参照

すべてのコンポーネント クラス
テクニカル リファレンス

  • No labels