I have a method needs to return boolean value, inside my method I need to do an asynchronous call to decide either return true or false. I tried to put return statement inside lambda expression, but it throws a return type is ‘void’ error
bool method()
{
domaincontext.Load(domaincontext.GetXXX(),
loadOperation =>
{
value = ???
}, null);
return value;
}
you cannot code like that. Silverlight will not allow you to query a web service and freeze the UI until the webservice returns. Silverlight’s asynchronous model is more like javascript, where you make a call and when the result returns you can decide what you want to do with it.
One way is to change the code on the caller to look like this: