public async void OnEnsureCoreWebView2_MarkupElement_ButtonClicked(object sender, RoutedEventArgs args) { if (_wv2_Markup != null) { try { await _wv2_Markup.EnsureCoreWebView2Async(); { SetEnsureCoreWebView2CompletionCount(_ensureCoreWebView2CompletionCount + 1); string s = string.Format("[{0}]: Got EnsureCWV2 Completion, ", _wv2_Markup.Name); _helpers.AppendMessage(s); Status2.Text = Status2.Text + " " + s; } } catch (Exception e) { SetClosedExceptionCount(_closedExceptionCount + 1); string s = string.Format("{0} Caught exception: {1}", _wv2_Markup.Name, e.ToString()); _helpers.AppendMessage(s); Status2.Text = Status2.Text + " " + s; } } }
public async void OnEnsure_Source_ButtonClicked(object sender, RoutedEventArgs args) { if (_wv2_ConcurrentCreation != null) { // We'll set Source in this special CWV2Initialized Handler _wv2_ConcurrentCreation.CoreWebView2Initialized += OnCoreWebView2Initialized_Source; // EnsureCWV2() await _wv2_ConcurrentCreation.EnsureCoreWebView2Async(); { SetEnsureCoreWebView2CompletionCount(_ensureCoreWebView2CompletionCount + 1); string s = string.Format("[{0}]: Got EnsureCWV2 Completion, ", _wv2_ConcurrentCreation.Name); _helpers.AppendMessage(s); Status2.Text = Status2.Text + " " + s; } } }
private async void OnCoreWebView2Initialized_Ensure(WebView2 sender, object args) { sender.CoreWebView2Initialized -= OnCoreWebView2Initialized_Ensure; // Don't spin creation on next CWV2Initialized! await sender.EnsureCoreWebView2Async(); { SetEnsureCoreWebView2CompletionCount(_ensureCoreWebView2CompletionCount + 1); string s = string.Format("[{0}]: Got EnsureCWV2 Completion, ", sender.Name); _helpers.AppendMessage(s); Status2.Text = Status2.Text + " " + s; } }