What is the use for Task.FromResult in C#

There are two common use cases I’ve found:

  1. When you’re implementing an interface that allows asynchronous callers, but your implementation is synchronous.
  2. When you’re stubbing/mocking asynchronous code for testing.

Leave a Comment