Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an alternative to Task.Delay(0) and Task.FromResult(0)? [duplicate]

I am attempting to create a Portable Class Library (.NET 4.5/Silverlight 5/Win Phone 8/WinRT) that takes advantage of the async/await feature set. I found that I need to include the Microsoft.Bcl.Async NuGet package in order to get this feature to work, so I did just that. Apparently due to my targets I do not have access to Task.Delay(0) or Task.FromResult(0). I was wondering what the next best alternative is?

Currently, I am using: new Task(() => { }) (basically, a Task that does not perform any action.)

I'm not sure if that is the best equivalent to either of the previously mentioned patterns.


Update: Apparently I'm blind and did not see TaskEx in my intellisense menu. I'm leaving the question open so people know that it is there, just easily missable because my intellisense kept autocompleting to TaskExtensions.

like image 696
myermian Avatar asked Dec 04 '22 08:12

myermian


1 Answers

FromResult and Delay are on the TaskEx type in the Microsoft.Bcl.Async library.

like image 135
Stephen Cleary Avatar answered Dec 28 '22 10:12

Stephen Cleary