Esempio n. 1
0
        /// <summary>
        /// 停止监听
        /// </summary>
        public void Stop()
        {
            if (!Running)
            {
                Log.Error(">未开始监听,无需停止");
                return;
            }
#if NETDNX
            AppDomain.CurrentDomain.ProcessExit -= CurrentDomain_ProcessExit;
#else
            AppDomain.CurrentDomain.DomainUnload -= CurrentDomain_DomainUnload;
#endif

            Log.Info(">准备停止监听");
            Stopping?.Invoke(this, EventArgs.Empty);
            if (RunningV4)
            {
                if (Stop_IPv4())
                {
                    System.Threading.Interlocked.CompareExchange(ref _running_v4, 0, 1);
                }
            }
            if (RunningV6)
            {
                if (Stop_IPv6())
                {
                    System.Threading.Interlocked.CompareExchange(ref _running_v6, 0, 1);
                }
            }
            Log.Info(">停止监听完成");
            Stoped?.Invoke(this, EventArgs.Empty);
            _endTime = System.DateTime.Now;
        }
Esempio n. 2
0
        static void ProxyStop(IntPtr h)
        {
            LogSharp.Debug("ProxyStop");
            UrhoPlatformInitializer.Initialized = false;
            var context = Current.Context;
            var app     = GetApp(h);

            app.IsClosed = true;
            app.UnsubscribeFromAppEvents();
            app.Stop();
            LogSharp.Debug("ProxyStop: Runtime.Cleanup");
            Runtime.Cleanup();
            LogSharp.Debug("ProxyStop: Releasing context");
#if ANDROID
            if (context.Refs() > 0)
            {
                context.ReleaseRef();
            }
#endif
            LogSharp.Debug("ProxyStop: Disposing context");
            context.Dispose();
            Current = null;
            Stoped?.Invoke();
            LogSharp.Debug("ProxyStop: end");
            exitTask?.TrySetResult(true);
        }
Esempio n. 3
0
        public void Stop()
        {
            cts?.Cancel();
            cts = null;

            try { stream.Close(); } catch { }
            try { tcpClient.Close(); } catch { }
            Stoped?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 4
0
        static void ProxyStop(IntPtr h)
        {
            UrhoPlatformInitializer.Initialized = false;
            var context = Current.Context;

            GetApp(h).Stop();
            Runtime.Cleanup();
            if (context.Refs() > 0)
            {
                context.ReleaseRef();
            }
            context.Dispose();
            Current = null;
            Stoped?.Invoke();
        }
        public static Tuple <long, int> NextBiggerNumberAndTime(long number)
        {
            DateTime Start;
            DateTime Stoped;
            TimeSpan Elapsed = new TimeSpan();

            Start = DateTime.Now;

            long nextNumber = NextBiggerNumber(number);

            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            int timeInMSec = (int)Elapsed.TotalMilliseconds;
            int timeInSec  = Elapsed.Seconds;

            return(Tuple.Create(nextNumber, timeInSec));
        }
Esempio n. 6
0
 void fireStopedEvent()
 {
     try
     {
         Task t = new Task(() =>
         {
             if (Stoped != null)
             {
                 try { Stoped.Invoke(this, null); }
                 catch (Exception)
                 { }
             }
         });
         t.Start();
     }
     catch (Exception)
     { }
 }
Esempio n. 7
0
        static async void ProxyStop(IntPtr h)
        {
            Current.ActionManager.CancelActiveActions();
            LogSharp.Debug("ProxyStop");
            UrhoPlatformInitializer.Initialized = false;
            var context = Current.Context;
            var app     = GetApp(h);

            app.IsClosed = true;
            app.UnsubscribeFromAppEvents();
            app.Stop();
            LogSharp.Debug("ProxyStop: Runtime.Cleanup");
            Runtime.Cleanup();
            LogSharp.Debug("ProxyStop: Disposing context");
            context.Dispose();
            Current = null;
            Stoped?.Invoke();
            LogSharp.Debug("ProxyStop: end");
            exitTask?.TrySetResult(true);
        }
        public void Stop()
        {
            try
            {
                MyProcess p = _process;
                if (p != null)
                {
                    _process = null;
                    KillProcess(p);
                    p.Dispose();

                    Console.WriteLine("kcptun stoped - " + p.server.FriendlyName());

                    if (Stoped != null)
                    {
                        Stoped.Invoke(this, new EventArgs());
                    }
                }
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }
Esempio n. 9
0
        public View3D( )
        {
            InitializeComponent();

            Loaded += UserControl_Loaded;


            _cameraFront = new Tuple <Vector3D, Point3D>(Camera.LookDirection, Camera.Position);
            _cameraSide  = new Tuple <Vector3D, Point3D>(new Vector3D(20.066, 0, -5.976), new Point3D(-17.066, 0, 20.976));

            //viewMover.Click += ( s, e ) =>
            //{
            //    viewMover.Content = _watchAtSide ? "Вид сбоку" : "Вид сзади";
            //    _watchAtSide = !_watchAtSide;
            //    if(_watchAtSide)
            //    {
            //        Camera.Position = _cameraSide.Item2;
            //        Camera.LookDirection = _cameraSide.Item1;
            //    }
            //    else
            //    {
            //        Camera.Position = _cameraFront.Item2;
            //        Camera.LookDirection = _cameraFront.Item1;
            //    }
            //};

            try
            {
                var path = ResourceFiles.GetFile(Config.Get().BoardBackImagePath);
                LayoutRoot.Background = new ImageBrush(new BitmapImage(new Uri(path)));
            }
            catch { }

            cancelButton.Click += async(s, e) => {
                var cur = await Task <bool> .Run(() => {
                    if (_state.Moves.Count < 1)
                    {
                        return(false);
                    }
                    var res = CancelLastMove?.Invoke();
                    return(res.HasValue && res.Value);
                });

                if (cur)
                {
                    var move = _state.Moves[_state.Moves.Count - 1];
                    MovePiece(new Point(move.Item2.Column + 1, 8 - move.Item2.Row), new Point(move.Item1.Column + 1, 8 - move.Item1.Row));
                }
            };
            resignButton.Click += (s, e) => {
                MainPresenter.Get().ShowQuestion("Хотите сдаться?", (val) => {
                    if (val)
                    {
                        Stoped?.Invoke();
                        GameLose();
                    }
                });
            };

            Border1.Fill   = Border2.Fill = Border3.Fill = Border4.Fill = SystemColors.ControlTextBrush;
            BoardPositions = new ChessPiece[8, 8];

            SetupButtons();

            #region [Setup all fields]
            _piecesReg = new List <Tuple <Model.Game.Chess.Figure, ChessPiece> > {
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackBishop, BBishop1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackBishop, BBishop2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackKnight, BKnight1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackKnight, BKnight2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackRook, BRook1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackRook, BRook2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackKing, BKing),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackQueen, BQueen),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteBishop, WBishop1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteBishop, WBishop2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteKnight, WKnight1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteKnight, WKnight2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteRook, WRook1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteRook, WRook2),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteKing, WKing),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhiteQueen, WQueen),

                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn2),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn3),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn4),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn5),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn6),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn7),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.BlackPawn, BPawn8),


                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn1),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn2),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn3),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn4),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn5),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn6),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn7),
                new Tuple <Model.Game.Chess.Figure, ChessPiece> (Model.Game.Chess.Figure.WhitePawn, WPawn8),
            };

            #endregion
        }
Esempio n. 10
0
 /// <summary>
 /// Calling the <c>Stoped</c> event
 /// </summary>
 protected virtual void OnStop()
 {
     Stoped?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 11
0
 private void Stop_Click(object sender, EventArgs e)
 {
     Stoped.Invoke(sender, e);
 }
Esempio n. 12
0
 public virtual void OnStop(Action baseOnStop)
 {
     baseOnStop();
     Stoped?.Invoke(Target, EventArgs.Empty);
 }
        public void OnDisconnected()
        {
            Log.Debug(TAG, "OnDisconnected");

            Stoped?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            int[]    DAT = new int[NUMS];
            int      a;
            Random   rnd = new Random();
            FileInfo f   = new FileInfo(@ "file.dat");

            using (BinaryWriter bw = new BinaryWriter(f.OpenWrite()))

                for (ulong i = 0; i < NUMS; i++)
                {
                    a = rnd.Next(0, 10000);
                    bw.Write(a);
                }

            using (BinaryReader br = new BinaryReader(f.OpenRead()))
                for (ulong i = 0; i < NUMS; i++)
                {
                    DAT[i] = br.ReadInt32();
                }
            Console.WriteLine();
            int[] vs = new int[NUMS];
            int[] vi = new int[NUMS];
            int[] sh = new int[NUMS];
            int[] fa = new int[NUMS];
            Array.Copy(DAT, 0, vs, 0, NUMS);
            Array.Copy(DAT, 0, vi, 0, NUMS);
            Array.Copy(DAT, 0, sh, 0, NUMS);
            Array.Copy(DAT, 0, fa, 0, NUMS);
            DateTime Start;
            DateTime Stoped;
            TimeSpan Elapsed = new TimeSpan();

            Console.WriteLine("Массив до пузырька: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", DAT[i]);
            }
            Start = DateTime.Now;
            puz(DAT, NUMS);
            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            Console.WriteLine("\nМассив после пузырька: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", DAT[i]);
            }
            Console.WriteLine(Environment.NewLine + "Время выполнения: " + Convert.ToString(Elapsed.TotalMilliseconds)); // Время выполнения в миллисекундах с плавующей запятой

            Console.WriteLine("\nМассив до вставки: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", vs[i]);
            }
            Start = DateTime.Now;
            insert(vs, NUMS);
            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            Console.WriteLine("\nМассив после вставки: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", vs[i]);
            }
            Console.WriteLine(Environment.NewLine + "Время выполнения " + Convert.ToString(Elapsed.TotalMilliseconds));

            Console.WriteLine("\nМассив до выбора: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", vi[i]);
            }
            Start = DateTime.Now;
            choose(vi, NUMS);
            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            Console.WriteLine("\nМассив после выбора: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", vi[i]);
            }
            Console.WriteLine(Environment.NewLine + "Время выполнения " + Convert.ToString(Elapsed.TotalMilliseconds));

            Console.WriteLine("\nМассив до слияния: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", sh[i]);
            }
            Start = DateTime.Now;
            myShakerSort(sh);
            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            Console.WriteLine("\nМассив после слияния: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", sh[i]);
            }
            Console.WriteLine(Environment.NewLine + "Время выполнения " + Convert.ToString(Elapsed.TotalMilliseconds));

            Console.WriteLine("\nМассив до быстрой: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", fa[i]);
            }
            Start = DateTime.Now;
            fast(fa);
            Stoped  = DateTime.Now;
            Elapsed = Stoped.Subtract(Start);
            Console.WriteLine("\nМассив после быстрой: ");
            for (ulong i = 0; i < NUMS; i++)
            {
                Console.Write(" {0}", fa[i]);
            }
            Console.WriteLine(Environment.NewLine + "Время выполнения " + Convert.ToString(Elapsed.TotalMilliseconds));

            Console.ReadKey();
        }