Пример #1
0
        public Form1()
        {
            InitializeComponent();

            Task.Run(() =>
            {
                int connected = 0;
                while (connected == 0)
                {
                    ConnectionStatus.BeginInvoke((Action)(() => {
                        ConnectionStatus.Text = "Connecting...";
                    }));

                    while ((connected = WiiUseBoard.Init()) == 0)
                    {
                        System.Threading.Thread.Sleep(500);
                    }

                    ConnectionStatus.BeginInvoke((Action)(() => {
                        ConnectionStatus.Text = "Connected";
                    }));

                    float weight, x, y;
                    while ((connected = WiiUseBoard.Read(out weight, out x, out y)) != 0)
                    {
                        Weight.BeginInvoke((Action)(() => {
                            Weight.Text = string.Format("{0:00.00} Kg", weight);
                        }));
                        System.Threading.Thread.Sleep(50);
                    }

                    WiiUseBoard.Shutdown();
                }
            });
        }