public async Task RunAsync() { try { if (_actionBeforeStart != null) { await _actionBeforeStart(_serviceProvider); } await TryStartSchedulerAsync(); await Task.Delay(-1); } finally { if (_actionBeforeFinish != null) { await _actionBeforeFinish(_serviceProvider); } await TryStopSchedulerAsync(); await _serviceProvider.DisposeAsync(); } }
public async Task AddDisposablesAndAsyncDisposables_DisposeAsync_AllDisposed(bool includeDelayedAsyncDisposable) { var services = new ServiceCollection(); services.AddSingleton <AsyncDisposable>(); services.AddSingleton <Disposable>(); if (includeDelayedAsyncDisposable) { //forces Dispose ValueTask to be asynchronous and not be immediately completed services.AddSingleton <DelayedAsyncDisposableService>(); } ServiceProvider sp = services.BuildServiceProvider(); var disposable = sp.GetRequiredService <Disposable>(); var asyncDisposable = sp.GetRequiredService <AsyncDisposable>(); DelayedAsyncDisposableService delayedAsyncDisposableService = null; if (includeDelayedAsyncDisposable) { delayedAsyncDisposableService = sp.GetRequiredService <DelayedAsyncDisposableService>(); } await sp.DisposeAsync(); Assert.True(disposable.Disposed); Assert.True(asyncDisposable.DisposeAsyncCalled); if (includeDelayedAsyncDisposable) { Assert.Equal(1, delayedAsyncDisposableService.DisposeCount); } }
private static async Task Shutdown() { var orleansClient = services.GetRequiredService <IClusterClient>(); await orleansClient.Close(); await services.DisposeAsync(); }
protected override async ValueTask OnDisposeAsync() { if (ServiceProvider != null) { await ServiceProvider.DisposeAsync().ConfigureAwait(false); } Dispose(false); }
/// <summary> /// Disposes underlying service provider async. /// </summary> protected virtual async ValueTask DisposeAsyncCore() { if (_serviceProvider is not null) { await _serviceProvider.DisposeAsync(); } _serviceProvider = null; }
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.</summary> /// <returns>A task that represents the asynchronous dispose operation.</returns> public async ValueTask DisposeAsync() { if (_serviceProvider != null) { await _serviceProvider.DisposeAsync() .ConfigureAwait(false); _serviceProvider = null; } }
public async Task DisposeAsync() { foreach (var dbContext in _dbContexts) { await dbContext.DisposeAsync(); } await Fixture.DropTestDb(); await _serviceProvider.DisposeAsync(); }
public async Task Teardown() { try { await TestHarness.Stop(); } finally { await Provider.DisposeAsync(); } }
private async Task ShutdownAsync() { _shuttingDown = true; await _log.Log(LogSeverity.Info, LogSource.Self, "Shutdown requested by Command"); await _client.StopAsync(); await _services.DisposeAsync(); Environment.Exit(0); }
public async Task Teardown() { try { await TestHarness.Stop(); } finally { await Provider.DisposeAsync(); } RestoreDefaultQuartzSystemTime(); }
public async Task Teardown() { try { await TestHarness.Stop(); await _testFixtureConfigurator.OneTimeTearDown(Provider); } finally { await Provider.DisposeAsync(); } }
public async ValueTask DisposeAsync() { if (_disposed) { return; } if (_disposer != null) { await _disposer.Invoke(this); } await _serviceProvider.DisposeAsync(); _disposed = true; }
public ValueTask DisposeAsync() => _sp.DisposeAsync();
public ValueTask DisposeAsync() => _services.DisposeAsync();
protected override void OnExit(ExitEventArgs e) { serviceProvider.DisposeAsync().AsTask().Wait(); base.OnExit(e); }
public ValueTask DisposeAsync() => serviceProvider.DisposeAsync();
/// <summary> /// 异步释放相关资源 /// </summary> /// <returns></returns> public ValueTask DisposeAsync() { return(_provider.DisposeAsync()); }
public ValueTask Cleanup() { return(_services.DisposeAsync()); }
/// <inheritdoc cref="IAsyncDisposable.DisposeAsync()"/> public ValueTask DisposeAsync() { return(_serviceProvider.DisposeAsync()); }
public async Task Close_container() { await _provider.DisposeAsync(); }
async Task IAsyncLifetime.DisposeAsync() { serviceScope.Dispose(); await serviceProvider.DisposeAsync(); }
async Task IAsyncLifetime.DisposeAsync() { await provider?.DisposeAsync().AsTask(); provider = null; }
public virtual async Task DisposeAsync() { await ServiceProvider.DisposeAsync(); Dispose(); }
public async ValueTask DisposeAsync() { await httpClientProvider.DisposeAsync().ConfigureAwait(false); GC.SuppressFinalize(this); }