2013-12-15 156 views
0

在Visual Studio 2012 .NET 4.5我有這個C#.NET 4.5的代碼到.NET 4.0

我可以在.NET 4.0 Visual Studio 2010中完全相同的行爲,而異步和等待,沒有掛用戶界面?

+2

你看到這個主題? http://stackoverflow.com/questions/9574790/creating-an-async-method-in-net-4-0-that-c​​an-be-used-with-await-in-net-4-5?rq= 1 – Dilish

+1

http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx – Damith

回答

1

是的,你可以使用此代碼:

//To invoke the OnCanExecuteChanged in same thread that the Execute method 
var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); 
_task.ContinueWith(t => OnCanExecuteChanged(), scheduler);