You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

[ |../../index.htm#lansa/vlfonetutorials_0530.htm]
Visual LANSA フレームワーク ガイド > チュートリアル > VLF-ONE Web アプリケーションのチュートリアル > 理解しておくと便利な事柄 > 非同期処理 > タイマーの作成

タイマーの作成

この演習では、コマンドとタイマーをフレームワークのツールバーに追加し、コマンド・ハンドラーを作成して、非同期処理によってユーザー・インターフェースがどのように更新されるかを確認します。
自分のフレームワークの [共通のアクティビティ] で、[新規コマンドをツールバーに追加] を選択します。コマンド名の XXXXX を Timer に変更し、コマンドのキャプションを タイマー にしてユーザー・インターフェースを持つかどうか (表示するかどうか) を指定します。
[作成] をクリックし、[作成してエディターで開く] を選択します。

 
"タイマー" コマンド・ハンドラーが作成され、スナップインされたら、タイマーのコンポーネントが開かれている、Visual LANSA エディターに切り替えます。
[ソース] タブに切り替えて、コードを次のコードに置き換えます。
Begin_Com Role(*EXTENDS #VF_AC010O) Height(241) Width(457)
Define_Com Class(#PRIM_LABL) Name(#VisibleCounter) Displayposition(1) Height(129) Left(16) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(56) Width(401) Verticalalignment(Center) Style(#BigFont) Caption('Stopped') Alignment(Center)
Define_Com Class(#Prim_phbn) Name(#StartCount) Parent(#COM_OWNER) Caption('Start Count') Displayposition(3) Tabposition(3)
Define_Com Class(#Prim_phbn) Name(#StopCount) Parent(#COM_OWNER) Caption('Stop Count') Displayposition(2) Tabposition(2) Left(96)
Define_Com Class(#Prim_vs.Style) Name(#BigFont) Fontsize(72) Textcolor(Blue)

  • ------------------------------------------------------------------------------
    Evtroutine Handling(#StartCount.Click)
    Define_Com Class(#std_Int) Name(#PhysicalCounter)
    #Com_Owner.avQueueAsyncOperation Operationid(Count) Parameterreference1(#PhysicalCounter)
    Endroutine
  • ------------------------------------------------------------------------------
    Evtroutine Handling(#StopCount.Click)
    #Com_Owner.avQueueAsyncOperation Operationid(Stop)
    Endroutine
  • ------------------------------------------------------------------------------
    Mthroutine Name(avExecuteAsyncOperation) Options(*REDEFINE)
    Define_Com Class(#std_Int) Name(#UseCounter) Reference(*DYNAMIC)
    Case (#OperationID)
    When (= Count)
    #UseCounter <= #ParameterReference1 *As #Std_Int
    #UseCounter += 1
    #VisibleCounter := #UseCounter.AsString
    #Com_Owner.avQueueAsyncOperation Operationid(Count) Parameterreference1(#UseCounter)
    When (= Stop)
    #VisibleCounter := "Stopped"
    #KillOtherPendingOperations := True
    Otherwise
    #SYS_WEB.Alert Caption("Unknown operation id " + #OperationID)
    Endcase
    Endroutine
    End_Com
     
    コマンド・ハンドラーをコンパイルします。
    ワークベンチでフレームワークを実行し、ツールバーのタイマーをクリックします。

     
    カウント開始をクリックして、タイマーを開始します。

     
     
    [ |../../index.htm#lansa/vlfonetutorials_0530.htm]
  • No labels