I have a method which returns a Task where the implementation may or may not need to perform a slow operation in order to retrieve the result. I would like to be able to si
You could use a TaskCompletionSource:
var tcs = new TaskCompletionSource(); tcs.SetResult(_Cache[key]); return tcs.Task;
(Note that if _Cache is a Dictionary you could use TryGetValue to make it a single lookup.)
_Cache
Dictionary
TryGetValue