c# - How to use the WebClient.DownloadDataAsync() method in this context? -
I plan to have a user write a movie title in my program and my program will pull Approvate information asynchronously UI does not stop.
Here is the code:
public class IMDB {webclient webclntx = new webclient (); Byte [] buffer = null; Public string [] SearchForMovie (String SearchPamator) {// Format the search parameter so that it can create a valid IMDB * Search * URL. // We are going to pull the actual movie // link from within the search website. String sitesearchURL = FindURL (SearchParameter); // One method / IMDB * search * Download the entire source code of the website asynchronously buffer = WebClientX.DownloadDataAsync (sitesearchURL); // Find the method to pass the IMDb source code (information) // string [] lol = findInformation (); // ??? //profit. String [] lol = null; Ability to return; }
My actual problem is in the WebClientX.DownloadDataAsync () method. I can not use a string URL for this. How can I use it to download site bytes (for later use I will convert it to string, I know how to do it) and my Without freeze the GUI?
Perhaps an explicit example of a DownloadDataAyncC cut example, how can I use it?
Thank you, you always have such great resources.
You need to control the DownloadDataCompleted
event:
related to error status in ARG etc. There are other pieces of information - also see them.
Also keep in mind that you DownloadDataCompleted
on a separate thread; if you are in UI (winform, wpf, etc.) Before updating the UI, you have to go to the UI thread. From Winforms, use this.Invoke
For WPF, see Dispatcher
.
Comments
Post a Comment