I figured it out from this article: How to use async-await with WCF in VS 2010 for WP7?
More: Async CTP - How can I use async/await to call a wcf service?
I wrote this on another class:
public static Task<int> InsertNewUser(string name, string phonenumber,string address) //can make it an extension method if you want.
{
TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();
service.InsertNewUserCompleted += (object sender, WebService.InsertNewUserCompletedEventArgs e) => //change parameter list to fit the event's delegate
{
if (e.Error != null) tcs.SetResult(-1);
else
tcs.SetResult((int)e.Result);
};
service.InsertNewUserAsync(name, phonenumber,address);
return tcs.Task;
}
then I could call it from my class:
int su = await WebServiceHelper.SignUp("blabla", "0123465","huehuehue");