Пример #1
0
        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);
 }
Пример #5
0
 /// <summary>
 /// Disposes underlying service provider async.
 /// </summary>
 protected virtual async ValueTask DisposeAsyncCore()
 {
     if (_serviceProvider is not null)
     {
         await _serviceProvider.DisposeAsync();
     }
     _serviceProvider = null;
 }
Пример #6
0
    /// <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();
        }
Пример #8
0
 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);
        }
Пример #10
0
        public async Task Teardown()
        {
            try
            {
                await TestHarness.Stop();
            }
            finally
            {
                await Provider.DisposeAsync();
            }

            RestoreDefaultQuartzSystemTime();
        }
Пример #11
0
        public async Task Teardown()
        {
            try
            {
                await TestHarness.Stop();

                await _testFixtureConfigurator.OneTimeTearDown(Provider);
            }
            finally
            {
                await Provider.DisposeAsync();
            }
        }
Пример #12
0
        public async ValueTask DisposeAsync()
        {
            if (_disposed)
            {
                return;
            }

            if (_disposer != null)
            {
                await _disposer.Invoke(this);
            }
            await _serviceProvider.DisposeAsync();

            _disposed = true;
        }
Пример #13
0
 public ValueTask DisposeAsync()
 => _sp.DisposeAsync();
Пример #14
0
 public ValueTask DisposeAsync() => _services.DisposeAsync();
Пример #15
0
 protected override void OnExit(ExitEventArgs e)
 {
     serviceProvider.DisposeAsync().AsTask().Wait();
     base.OnExit(e);
 }
Пример #16
0
 public ValueTask DisposeAsync() => serviceProvider.DisposeAsync();
Пример #17
0
 /// <summary>
 /// 异步释放相关资源
 /// </summary>
 /// <returns></returns>
 public ValueTask DisposeAsync()
 {
     return(_provider.DisposeAsync());
 }
Пример #18
0
 public ValueTask Cleanup()
 {
     return(_services.DisposeAsync());
 }
Пример #19
0
 /// <inheritdoc cref="IAsyncDisposable.DisposeAsync()"/>
 public ValueTask DisposeAsync()
 {
     return(_serviceProvider.DisposeAsync());
 }
Пример #20
0
 public async Task Close_container()
 {
     await _provider.DisposeAsync();
 }
Пример #21
0
 async Task IAsyncLifetime.DisposeAsync()
 {
     serviceScope.Dispose();
     await serviceProvider.DisposeAsync();
 }
Пример #22
0
        async Task IAsyncLifetime.DisposeAsync()
        {
            await provider?.DisposeAsync().AsTask();

            provider = null;
        }
Пример #23
0
        public virtual async Task DisposeAsync()
        {
            await ServiceProvider.DisposeAsync();

            Dispose();
        }
Пример #24
0
    public async ValueTask DisposeAsync()
    {
        await httpClientProvider.DisposeAsync().ConfigureAwait(false);

        GC.SuppressFinalize(this);
    }