Esempio n. 1
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);
        }
 public static async Task ServerStop()
 {
     aTimer?.Dispose();
     if (host.State != CommunicationState.Faulted)
     {
         host?.BeginClose(null, null);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Stop this service
 /// </summary>
 public void Stop()
 {
     if (host != null)
     {
         host.BeginClose(null, null);
         // host.Abort();
         shutdownFlag.Set();
     }
 }
Esempio n. 4
0
        public bool Stop(HostControl hostControl)
        {
            _ordersHost.BeginClose(OnClose, _ordersHost);
            _productsHost.BeginClose(OnClose, _productsHost);
            _categoriesHost.BeginClose(OnClose, _categoriesHost);

            /*while (_ordersHost.State != CommunicationState.Closed && _categoriesHost.State != CommunicationState.Closed && _productsHost.State != CommunicationState.Closed)
             * {
             *      Thread.Sleep(100);
             * }*/

            return(true);
        }
Esempio n. 5
0
 public void Stop(Action Successfully = null, Action Failed = null)
 {
     _host?.BeginClose((res) => {
         if (res.IsCompleted && _host.State == CommunicationState.Closed)
         {
             Successfully?.Invoke();
         }
         else
         {
             Failed?.Invoke();
         }
     }, null);
 }
        /// <summary>
        /// 閉じる(非同期)
        /// </summary>
        public async Task CloseAsync(object instance)
        {
            if (!Closed)
            {
                if (Proxy != null)
                {
                    ((IClientChannel)Proxy).Abort();
                    Proxy = null;
                }
                await Task.Factory.FromAsync(Server.BeginClose(_ => { }, instance), _ => { });

                Closed = true;
            }
        }
        public void Stop()
        {
            if (_listenerServiceHost != null)
            {
                _listenerServiceHost.Dispose();
                _listenerServiceHost = null;
            }

            if (_nativeServiceHost != null)
            {
                if (_nativeServiceHost.State != CommunicationState.Faulted)
                {
                    _nativeServiceHost.BeginClose(null, null);
                }
                _nativeServiceHost = null;
            }

            if (_serviceHost != null)
            {
                if (_serviceHost.State != CommunicationState.Faulted)
                {
                    _serviceHost.BeginClose(null, null);
                }
                _serviceHost = null;
            }

            if (_service != null)
            {
                _service.Dispose();
                _service = null;
            }

            if (_remoteServer != null)
            {
                _remoteServer.Dispose();
                _remoteServer = null;
            }

            if (_server != null)
            {
                _server.Stop();
                _server = null;
            }
        }
Esempio n. 8
0
        public bool UnInitialize()
        {
            TracerHelper.TraceEntry();

            lock (this)
            {
                if (_serviceHost != null && _serviceHost.State != CommunicationState.Closed)
                {
                    _serviceHost.BeginClose(TimeSpan.FromSeconds(2), null, null);
                    _serviceHost.Abort();
                    _serviceHost.Close();
                    _serviceHost = null;
                }

                if (_reconectionTimer != null)
                {
                    _reconectionTimer.Dispose();
                    _reconectionTimer = null;
                }
            }

            return(true);
        }
Esempio n. 9
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. 10
0
 /// <summary>
 /// Begins an asynchronous operation to close a communication object with a specified timeout.
 /// </summary>
 /// <param name="timeout">The System.Timespan that specifies how long the send operation has to complete before timing out.</param>
 /// <param name="callback">The System.AsyncCallback delegate that receives notification of the completion of the asynchronous close operation.</param>
 /// <param name="state">An object, specified by the application, that contains state information associated with the asynchronous close operation.</param>
 /// <returns>The System.IAsyncResult that references the asynchronous close operation.</returns>
 public IAsyncResult BeginClose(TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(ServiceHost.BeginClose(timeout, callback, state));
 }