public ActionResult Index(int id) { var model = new Model(); model.Customer = this.dataAccess.Get(id); Owned <DataAccess> dataAccessForAsyncTaskHolder = null; try { dataAccessForAsyncTaskHolder = dataAccessFactory(); dataAccessForAsyncTaskHolder.Value.ExecuteAsyncTask(() => // you'll need a completion callback { // finish the task if required // dipose the owned instance dataAccessForAsyncTaskHolder.Dispose(); }); } catch { if (dataAccessForAsyncTaskHolder != null) { dataAccessForAsyncTaskHolder.Dispose(); } throw; } return(View(model)); }
private async Task Handle(SuccesLogin authorization) { logger.Info("Handle SuccesLogin"); Loading = true; loginViewModel.Dispose(); Loading = false; await base.BeginLogonSession(); }
protected override void Dispose(bool disposing) { if (disposing) { _ownedValue.Dispose(); } }
public void DisposingOwned_CallsDisposeOnLifetimeToken() { var lifetime = new DisposeTracker(); var owned = new Owned<string>("unused", lifetime); owned.Dispose(); Assert.True(lifetime.IsDisposed); }
protected virtual void Dispose(bool disposing) { if (disposing) { _ownedInstance?.Dispose(); } }
public void ReportOnce() { log.Value.Write("Log started"); // we do not call log.Value.Dispose() - slight difference in syntax log.Dispose(); Console.WriteLine("Log disposed"); }
public void M() { //_b用于某个任务 _b.Value.DoSomething(); //这里_b不再需要,所以它被释放 _b.Dispose(); }
public void DisposingOwned_CallsDisposeOnLifetimeToken() { var o = new MockDisposable(); var owned = new Owned <string>("unused", o); owned.Dispose(); Assert.AreEqual(1, o.disposed); }
public void DisposingOwned_CallsDisposeOnLifetimeToken() { var lifetime = new Mock<IDisposable>(); lifetime.Setup(l => l.Dispose()).Verifiable(); var owned = new Owned<string>("unused", lifetime.Object); owned.Dispose(); lifetime.VerifyAll(); }
protected override void Dispose(bool disposing) { if (_optionsPageControl != null) { _optionsPageControl.Dispose(); } base.Dispose(disposing); }
public void DisposingOwned_CallsDisposeOnLifetimeToken() { var lifetime = new Mock <IDisposable>(); lifetime.Setup(l => l.Dispose()).Verifiable(); var owned = new Owned <string>("unused", lifetime.Object); owned.Dispose(); lifetime.VerifyAll(); }
public void Handle() { try { _command.Value.Execute(); } finally { _command.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _hostEvents.Dispose(); _siteLifetimeScope.Dispose(); _rootLifetimeScope.Dispose(); } _disposed = true; }
public async Task Run(IWorkContext context) { context.Verify(nameof(context)).IsNotNull(); context = context .WithCreateLogger(nameof(SendEvents)) .With(_tag); context.Telemetry.Info(context, $"Sending events, Task Count:{_option.TaskCount}, ..."); try { await SendMessagesToEventHub(context); } finally { await _sendEvent.Value.CloseAsync(context); _sendEvent.Dispose(); } context.Telemetry.Info(context, "Completed sending events..."); }
public void ReportOnce() { ownedLogger.Value.Write("Report once"); ownedLogger.Dispose(); }
public void ReportOnce() { _loggerOwned.Value.Write("Log started"); _loggerOwned.Dispose(); }
public void Report() { log.Value.Write("Report from consolelog"); log.Dispose(); }
public void Dispose() { _ownedExecutor.Dispose(); }
public void Dispose() { _ownedDeployer.Dispose(); }
public void The_Dipose_call_count_is_1() { _ownedDisposable.Dispose(); Assert.AreEqual(1, Disposable.DisposeCallCount); }
public void ReportOnce() { log.Value.Write("Log started"); log.Dispose(); // ConsoleLog의 Dispose()가 아니라 Autofac의 Dispose()이다 }
public void Stop() { cancellationTokenSource.Cancel(); watchdog?.Dispose(); watchdog = null; }
public void Dispose() { UnsubscrubeOnExchangesEvents(); _produserOwner.Dispose(); }
public void ReportOnce() { log.Value.Write("Log started"); log.Dispose(); }
public void SimpleDisposableTest() { Owned<IDisposableService> owned = new Owned<IDisposableService>(); DisposableService disposableService = new DisposableService(); bool eventFired = false; disposableService.Disposing += (sender, args) => eventFired = true; owned.SetValue(disposableService); Assert.True(ReferenceEquals(owned.Value, disposableService)); owned.Dispose(); Assert.True(eventFired); }
public void Report(string message) { _log.Value.Log(message); _log.Dispose(); }
private void OnUnloaded(object sender, RoutedEventArgs e) { OnUnloaded(); View = null; _owned?.Dispose(); }
public void Dispose() { _xxx.Dispose(); }
public void Dispose() { _root.Dispose(); }
public void ReportOnce() { log.Value.Write("Log started"); log.Dispose(); // Call it on owned type }
public void PrintToken() { Console.WriteLine(_ownedDtoToken?.Value?.Guid); _ownedDtoToken?.Dispose(); }
public void SimpleNonDisposableTest() { Owned<IBasicService> owned = new Owned<IBasicService>(); BasicService basicService = new BasicService(); owned.SetValue(basicService); Assert.True(ReferenceEquals(owned.Value, basicService)); owned.Dispose(); }
/// <summary> /// Disposes of the owned instance. /// </summary> public override void Dispose() { owned.Dispose(); }