There are cases that I would want to run a task conditionally. I use some sort of extension method like this:
public static class MyTaskExtension{
private stat
As long as you hand back a task that is in the completed state (use TaskCompletionSource
to do this), I can't think of any problem with this since there aren't really any setters on the Task
class that would allow the client to muck with your static empty task. They could call Dispose()
on your task, but I don't think that would cause any harm (i.e. I don't think it would affect the ability to inspect the properties of the Task (haven't tried it out--something worth testing out)).