How To Asynchronously Resolve a Type |
This topic details the steps necessary for asynchronously resolving a type from a Unity container.
Make sure the resolved type is registered with the container, either directly or as the target type in a mapping .
This example assumes a prior registration of a mapping of IUniversalAnswerService to UniversalAnswerService.
Import the Unity Container Async Extensions namespace:
using Ditto.AsyncInit.Unity;
Resolve the type asynchronously:
var service = await container.ResolveAsync<IUniversalAnswerService>(cancellationToken); var answer = service.Answer;
Unity Container Async Extensions provide support for advanced resolution scenarios through overloads of ResolveAsync.