public IHttpActionResult New() { var o = new AsyncConstructor(); // Even if this was an Async Task<> there's nothing to await return(Ok(o.Message)); }
public async Task <IHttpActionResult> Yield() { var o = new AsyncConstructor(); // NOT RECOMMENDED!!! // Remember, async doesn't create another thread // So this thread needs to be assigned to complete the 'Delay' task // Yield appears to do the trick // But, like so many cases, the issue is the exception is lost! for (var i = 0; i < 100 && o.Completed == false; i++) // Infinite loop { await Task.Yield(); await Task.Delay(10); } return(Ok(o.Message)); }
public void New() { var o = new AsyncConstructor(); Assert.IsTrue(o.Completed); }