I understand that the previous answer here could be true a couple of years ago, but now this is not quite the way I just discovered. Look at the wait statement http://msdn.microsoft.com/en-us/library/hh156528.aspx
I think this is exactly what you are looking for. You can call it from the asynchronous method (you must use the async modifier at the beginning of the method, for example: private async void dostuff ()). Although the parent method is still asynchronous, it will wait for the task to be called.
Say you are doing this from a domain data service. Here is an example: Note. DDS should return an IEnumerable type. Before you call data from your DDS, define a private task method that retrieves the data in question, for example:
private Task<IEnumerable<fieldCounts>> GetCountssAsync() { fieldCountsEnumerable_DS _context = new fieldCountsEnumerable_DS (); return _context.LoadAsync(_context.GetCountsQuery()); }
You can then call this task from an existing async ria service method or any client method that really uses:
IEnumerable<fieldCounts> fieldcnts = await GetCountssAsync(); enter code here
Just know, no matter what method you call it, this method should be asynchronous, as in the documentation. It must return control to the caller.
source share