I have a hierarchy of async calls I'm making. Looks basically like this:
async MyObject MainWorker()
{
return await Task.Run(SomeSynchronousFunction);
}
async MyObject InbetweenFunction1()
{
//do some things
return await MainWorker();
}
async MyObject InbetweenFunction2()
{
//do some things
return await MainWorker();
}
void ReturnObject TopFunction()
{
Task<MyObject> return1 = InbetweenFunction1();
Task<MyObject> return2 = InbetweenFunction2();
while (!return1.IsComplete || !return2.IsComplete)
Thread.Sleep(100);
//access return1.Return and return2.Return values and return from this function
}
So I have a few levels of async calls. The top level method makes two async calls, waits for them to complete (via polling) and then accesses their return values and does something with the values. The problem is, none of the async calls ever finish. The function SomeSynchronousFunction which is called asynchronously with Task.Run should take a few seconds tops, but I wait 30+ seconds and no results.
This is my first attempt at using the new async/await keywords. Am I doing something obviously wrong?