Пример #1
0
        public void Stop(bool force = false)
        {
            Disposed = true;

            if (!force)
            {
                try
                {
                    tcp?.StopNetworking(!force);
                    DateTime startDT = DateTime.Now;

                    while (tcp?.client != null && ((DateTime.Now - startDT).TotalMilliseconds) < 1500) // wait timeout
                    {
                        Thread.Sleep(50);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Something went terribly wrong when stopping tcp networking");
                }
            }

            try
            {
                tcp?.Kill();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Something went terribly wrong when killing tcp");
            }
            try
            {
                udp?.Kill();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Something went terribly wrong when killing udp");
            }
            try
            {
                hub?.Kill();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Something went terribly wrong when killing hub");
            }
            try
            {
                watch?.Kill();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Something went terribly wrong when killing watch");
            }

            logger.Debug($"NetCore {(force ? "Killed" : "Stopped")}");
        }
Пример #2
0
        public void Stop(bool force = false)
        {
            Disposed = true;

            if (!force)
            {
                tcp?.StopNetworking(!force);
                DateTime startDT = DateTime.Now;

                while (tcp?.client != null && ((DateTime.Now - startDT).TotalMilliseconds) < 1500) // wait timeout
                {
                    Thread.Sleep(50);
                }
            }

            tcp?.Kill();
            udp?.Kill();
            hub?.Kill();
            watch?.Kill();

            ConsoleEx.WriteLine($"NetCore {(force ? "Killed" : "Stopped")}");
        }