2016-12-08 16 views
0

javascript関数(AddToPage)でテキストがwebviewに追加された後、私のPlay()関数が呼び出されることを確認する必要があります。 awaitキーワードは、javascript関数が完全に実行されたことを確認するか、呼び出しが行われるまで待つだけですか?UWP:invokeScriptAsyncが完了するまで待つ

private async void AddChunk(ChunkEventArgs chunkargs) 
    { 
     Debug.WriteLine("AddChunk called: " + chunkargs.Text); 

     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,async() => 
     { 
      if (!string.IsNullOrEmpty(chunkargs.Text)) 
      { 
       string text = App.chunkparser.ParseChunk(chunkargs.Text); 

       Debug.WriteLine("calling addparsedchunk"); 
       CurrentDocument.AddParsedChunk(App.chunkparser.ElementFromChunk); 

       await _webView.InvokeScriptAsync("AddToPage", new string[] { text }); 

       if (App.settings.AutoPlay && !SpeechControl.IsSpeaking) 
        Play(); 
      } 
     }); 
    } 

答えて

0

InvokeScriptAsyncスクリプトが終了するまで待ちます。

  • それはスクリプトが終了した場合にのみ可能であるスクリプトの結果を返す
  • documentationが明確方法は、スクリプト完了
を待つことを示す Your app might appear unresponsive while scripts are running. Handle the LongRunningScriptDetected event to interrupt a long-running script.言います
関連する問題