/// <summary> /// Prompt the user to name a CDP event, and then subscribe to that event. /// </summary> public void SubscribeToCdpEvent() { TextInputDialog dialog = new TextInputDialog( "Subscribe to CDP Event", "CDP event name:", "Enter the name of the CDP event to subscribe to.\r\n" + "You may also have to call the \"enable\" method of the\r\n" + "event's domain to receive events (for example \"Log.enable\").\r\n", "Log.entryAdded", false); if (dialog.ShowDialog() == true) { string eventName = dialog.Input; // If we are already subscribed to this event, unsubscribe first. if (!string.IsNullOrEmpty(eventName)) { _webView2.StopListeningDevToolsProtocolEvent(eventName); } _webView2.StartListeningDevToolsProtocolEvent(eventName); } }