private Task LoadCoreAsync() { AbstractMultiLifetimeInstance instance; lock (_lock) { if (_instance == null) { _instance = CreateInstance(); } instance = _instance; } return(instance.InitializeAsync()); }
public Task UnloadAsync() { AbstractMultiLifetimeInstance instance = null; lock (_lock) { if (_instance != null) { instance = _instance; _instance = null; } } if (instance != null) { return(instance.DisposeAsync()); } return(Task.CompletedTask); }