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

4k views Asked by At

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.

1

There are 1 answers

0
Stephen Cleary On BEST ANSWER

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