Bug 12440 - The task has not finished yet
Summary: The task has not finished yet
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-05-28 18:54 UTC by Alberto León
Modified: 2013-05-29 15:37 UTC (History)
2 users (show)

See Also:
Tags: async, .Net 4.5, await
Is this bug a regression?: ---
Last known good build:

The ASP.NET MVC4 application using async and await (3.85 MB, application/x-tar)
2013-05-29 15:37 UTC, Alberto León

Description Alberto León 2013-05-28 18:54:40 UTC
Using async and task always return the task has not finished yet

The task has not finished yet

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /home/alberto/Documentos/git/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62 at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00021] in /home/alberto/Documentos/git/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter.cs:57 at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Threading.Tasks.Task) <IL 0x00009, 0x00063> at System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted (System.Threading.Tasks.Task) <IL 0x00007, 0x00035> at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute (System.IAsyncResult) <IL 0x0000f, 0x0007f> at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass21.<BeginInvokeAsynchronousActionMethod>b__20 (System.IAsyncResult) <IL 0x00008, 0x0003f> at System.Web.Mvc.Async.AsyncResultWrapper/WrappedAsyncResult`1<System.Web.Mvc.ActionResult>.End () <0x00103> at System.Web.Mvc.Async.AsyncResultWrapper.End<System.Web.Mvc.ActionResult> (System.IAsyncResult,object) <0x00073> at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (System.IAsyncResult) <IL 0x00007, 0x0003f> at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass19/<>c__DisplayClass1b.<BeginInvokeActionMethodWithFilters>b__15 () <IL 0x00030, 0x000a6> at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass31.<InvokeActionMethodFilterAsynchronously>b__2b () <IL 0x0000a, 0x00065> 

I run it from MonoDevelop 3.10 in Ubuntu, the project's runtime is 4.5
The mono version is 3.0.12

I needed to copy xsp4 from /opt/mono-3.0.10/lib/mono/4.0 to /opt/mono-3.0.10/lib/mono/4.5 because it's not any exe for xsp4 or mono-server4

The code failing is:

public async Task<ViewResult> Rss()
			var client = new HttpClient();
			var step1 = await client.GetStringAsync("https://github.com/mono/mono/commits/master.atom");
			var step2 = await client.GetStringAsync("https://aspnetwebstack.codeplex.com/project/feeds/rss");
			var step3 = await client.GetStringAsync("https://orchard.codeplex.com/project/feeds/rss");
			ViewBag.MonoActivity = GetItems(step1);
			ViewBag.MVC4Activity= GetItems(step2);
			ViewBag.OrchardActivity= GetItems(step3);

			return View();

		public IList<SyndicationItem> GetItems(String xml)
			var textReader = new StringReader(xml);
			var xmlReader = XmlReader.Create(textReader);
			var feed = SyndicationFeed.Load(xmlReader);
			return feed == null ? null : new List<SyndicationItem>(feed.Items);
Comment 1 Marek Safar 2013-05-29 04:15:54 UTC
Could you try it again with master mono version newer than commit 8cabf341f7172e7c96d7c4eb72636d9729bc2a2a ?

Or provide self contained test case I can run. 

Secondly, I don't think Mono ASP.NET implementation has been updated to deal with Tasks so it may still not work. For example there is no UseTaskFriendlySynchronizationContext support
Comment 2 Alberto León 2013-05-29 15:37:57 UTC
Created attachment 4042 [details]
The ASP.NET MVC4 application using async and await

This is the application I coded to use asyn and await with ASP.NET MVC4 in Mono.
You need to configure web.config with the twitter API keys and run mozroots --import --sync to allow mono to connect to twitter.

The failing application is in the Home Controller, Method Rss

Note You need to log in before you can comment on or make changes to this bug.