private void OnClose(IAsyncResult result) { ServiceHost service = (ServiceHost)result.AsyncState; service.EndClose(result); ((IDisposable)service).Dispose(); }
public bool Stop(HostControl hostControl) { var ordersResetEvent = new ManualResetEvent(false); var catResetEvent = new ManualResetEvent(false); var prodResetEvent = new ManualResetEvent(false); _ordersHost.BeginClose(ar => { _ordersHost.EndClose(ar); ordersResetEvent.Set(); }, null); _productsHost.BeginClose(ar => { _productsHost.EndClose(ar); prodResetEvent.Set(); }, null); _categoriesHost.BeginClose(ar => { _categoriesHost.EndClose(ar); catResetEvent.Set(); }, null); WaitHandle.WaitAll(new WaitHandle[] { ordersResetEvent, catResetEvent, prodResetEvent }); return(true); }
void OnClose(IAsyncResult ar) { ServiceHost service = (ServiceHost)ar.AsyncState; service.EndClose(ar); Dispose(); }
public Task ShutdownAsync(CancellationToken cancellationToken = default) { Log.Debug().WriteLine("Stopping Greenshot server"); return(Task.Factory.FromAsync((callback, stateObject) => _host.BeginClose(callback, stateObject), asyncResult => _host.EndClose(asyncResult), null)); }
/// <summary> /// Completes an asynchronous operation to close a communication object. /// </summary> /// <param name="result">The System.IAsyncResult that is returned by a call to the System.ServiceModel.ICommunicationObject.BeginClose method.</param> public void EndClose(IAsyncResult result) { ServiceHost.EndClose(result); }