Archived Forum Post

Index of archived forum posts


C#: Can a Task of *Async-Methods be null?

Jan 10 '16 at 01:36


is it possible to get a null Task? I'd like to skip the null check. Looks unnecessary.

Thanks in advance

Accepted Answer

Typically, it should never return null. The only case (thinking off the top of my head) is if somehow the program ran out of memory just at the point of creating the task -- which would be highly unlikely. If there's even a small chance that something could fail, then Chilkat must be able to return either null or false. Not checking for null leaves open the very very tiny possibility that your program could crash rather than fail gracefully.


Thanks for your answer. When my program runs out of momery I will get an OutOfMemoryException anyway.