I am writing a program that has to access a MySQL database. To do this I wrote a PHP WebService to get all the values in a table. The problem I am having is that I am writing a function in C# to get those values. I want the function to wait until a event handler on the DownloadStringCompleted event is called, then return the values. I did it like this:
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadCompletedHandler);
client.DownloadStringAsync(new Uri(Application.Current.Host.Source.AbsoluteUri + "\\PHP\\GetAdmins.php"));
while (DownloadCompleted == false) { }
return DownloadResult;
But that makes the program hang.
I need something that will make that part of the program pause until DownloadConpleted = true.
I am running Visual Studio Ultimate 2010, I am making a Silverlight application, and any help will be appreciated.