public ActionResult QBWIPage() { Log.Info("QBQIPage ==>"); ViewBag.Message = "QBWI Page Here"; HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => { try { cancellationToken.ThrowIfCancellationRequested(); for (int i = 0; i < 20; i++) { var duration = i * 1000; AsyncToSync.GetStringAsync(duration) .ContinueWith(t => { Log.Info($"QBWI - StringAsync Completed duration: #{duration}"); }, cancellationToken); } } catch (Exception e) { Log.Info("QueueBackgroundWorkItem - Exception", e); } }); MyPage myPage = new MyPage { Content = "QBWI - Page Here" }; ViewBag.MyPage = myPage; return(View()); }
public async Task <ActionResult> AsyncPage() { Log.Info("AsyncPage ==>"); ViewBag.Message = "Async Page Here"; MyPage myPage = new MyPage { Content = await AsyncToSync.GetStringAsync() }; ViewBag.MyPage = myPage; return(View()); }