I have this simple code
static string ParentMethod()
{
1 var response = ChildMethod("param1")
2 string value = response.Result;
3
4 return value;
}
static async Task<string> ChildMethod(string param1)
{
1 string value = "";
2
3 var response = await Task.Run(() => SomeAPIDLL.SendSsMessage(param1));
4
5 if (response.RestExcpetion != null)
6 value = response.RestException.Message;
7
8 return value;
}
Not sure why but on the ChildMethod, after the Task.Run the debugger immediately points back to ParentMethod line 2 where at that point it executes the call (since I get a text message) but then never reads the Result and hangs in nowhere-lands, the client hangs, VS never recovers and I have to stop the Debugging to return to normal.
Is the problem the fact that if I have a ChildMethod Async, I have to MARK all parent calling methods Async too, all the way till the API public method?