CancellationToken & AsyncLazy

May 2, 2014 at 2:52 PM
Is there a way to add the handling of CancellationToken with AsyncLazy? Let's say I want the lazy factory to be cancelled if the request doesn't need it anymore?

Carl.
Coordinator
May 2, 2014 at 5:31 PM
You can pass a CancellationToken into the factory method. However, be aware that if the factory method is canceled, then the resource creation will be canceled. All code awaiting that instance will throw an OperationCanceledException.

-Steve