Esempio n. 1
0
        private void OnClose(IAsyncResult result)
        {
            ServiceHost service = (ServiceHost)result.AsyncState;

            service.EndClose(result);
            ((IDisposable)service).Dispose();
        }
Esempio n. 2
0
        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();
    }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 /// <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);
 }