private void MathView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { if (args.ExecutionTime > TimeSpan.FromMilliseconds(5000)) { args.StopPageScriptExecution = true; } }
// 当脚本运行时,可能会导致 app 无响应。此事件会定期执行,然后可查看 ExecutionTime 属性,如果要暂停脚本,则将 StopPageScriptExecution 属性设置为 true 即可 void webView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { // 获取 WebView 执行的一个长时间运行的脚本的运行时间(单位:毫秒) // args.ExecutionTime // 是否暂停在 WebView 中执行的已运行很长时间的脚本 // args.StopPageScriptExecution }
/// <summary> /// Apply some constraints to take action on long running scripts /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void ContentView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { //Halt script running more than 30 secs if (args.ExecutionTime > new TimeSpan(0, 0, 30)) { args.StopPageScriptExecution = true; InProgress = false; } }
private void WebView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { LogService.Write(); // Halt script running more than 30 secs if (args.ExecutionTime > _longRunningTime) { args.StopPageScriptExecution = true; ViewModel.InProgress = false; } }
private void web_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { args.StopPageScriptExecution = true; }
private void wvMain_LongRunningScriptDetected(Windows.UI.Xaml.Controls.WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { SendMessage?.Invoke(null, new ContentViewEventArgs() { Type = "LongRunningScriptDetected" }); }
private void WebView_OnLongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { }
private void WbView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { //args.StopPageScriptExecution = true; System.Diagnostics.Debug.WriteLine("WbView_LongRunningScriptDetected"); }
bool IWebViewLongRunningScriptDetectedEventArgsResolver.StopPageScriptExecution(WebViewLongRunningScriptDetectedEventArgs e) => e.StopPageScriptExecution;
TimeSpan IWebViewLongRunningScriptDetectedEventArgsResolver.ExceptionTime(WebViewLongRunningScriptDetectedEventArgs e) => e.ExecutionTime;
/// <summary> /// Halts a long-running script executing in a <see cref="WebView"/> control. /// </summary> /// <param name="e">The requested <see cref="WebViewLongRunningScriptDetectedEventArgs"/>.</param> /// <returns> /// <c>true</c> to halt the script; otherwise, <c>false</c>. /// </returns> public static bool StopPageScriptExecution(this WebViewLongRunningScriptDetectedEventArgs e) => Resolver.StopPageScriptExecution(e);
/// <summary> /// Gets the number of milliseconds that the <see cref="WebView"/> control has been executing a long-running script. /// </summary> /// <param name="e">The requested <see cref="WebViewLongRunningScriptDetectedEventArgs"/>.</param> /// <returns>The number of milliseconds the script has been running.</returns> public static TimeSpan ExceptionTime(this WebViewLongRunningScriptDetectedEventArgs e) => Resolver.ExceptionTime(e);
private void WebView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { }
public void webView_LongRunningScriptDetected(WebView sender, WebViewLongRunningScriptDetectedEventArgs args) { /* WebViewPage.InfoDialog.IsOpen = true; * WebViewPage.InfoDialog.Title = "Long running script"; * WebViewPage.InfoDialog.IsLightDismissEnabled = false;*/ }