I am calling into this static login method with username and password. I want it to wait to return until the downloadstringasync has completed. For the freaking life of me I cant get it to wait though.
I tried the oldschool
while(wc.IsBusy){} //Which froze
also tried a variety of async crap that didnt even compile
public static dbObj Login(String username, String password)
{
dbObj ret = new dbObj();
String rawWebReturn = "";
ret.propBag.Add(_BAGTYPE,returnTypes.Login.ToString());
DateTime date = DateTime.Now;
WebClient wc = new WebClient();
wc.DownloadStringAsync(new Uri(baseLoginURI + "uname=" + username + "&pword=" + password + "&date=" + date.ToString()));
wc.DownloadStringCompleted += (s,e) => {
if(e.Error!=null)
rawWebReturn = e.Error.Message;
else
rawWebReturn = e.Result;
};
return parseWebReturn(rawWebReturn,ret);
}