Пример #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            form = new JumpRopeForm();

            //connect to the Balance Board
            ConnectBalanceBoard();
            if (form == null)
            {
                return;               //connecting required application restart, end this process here.
            }
            //Continue running BoardTimer_tick()
            BoardTimer          = new System.Windows.Forms.Timer();
            BoardTimer.Interval = 50;
            BoardTimer.Tick    += new System.EventHandler(BoardTimer_Tick);
            BoardTimer.Start();

            Application.Run(form);
            Shutdown();
        }
Пример #2
0
        static void Shutdown()
        {
            if (BoardTimer != null)
            {
                BoardTimer.Stop();
                BoardTimer = null;
            }

            if (connectionManager != null)
            {
                connectionManager.Cancel();
                connectionManager = null;
            }

            if (form != null)
            {
                if (form.Visible)
                {
                    form.Close();
                }
                form = null;
            }
        }