public void DownloadHtmlStringWithEvent(string url) { var html = MyWebClient.DownloadString(url); EventHandler <HtmlReceivedEventArgs> handler = HtmlStringReceived; var args = new HtmlReceivedEventArgs { Html = html }; if (null != handler) { handler(this, args); } }
public async Task <string> DownloadHtmlString(string url) { var task = MyWebClient.DownloadStringTaskAsync(url); var result = await task; EventHandler <HtmlReceivedEventArgs> handler = HtmlStringReceived; var args = new HtmlReceivedEventArgs { Html = result }; if (null != handler) { handler(this, args); } return(result); }