コード例 #1
0
        public void PollingThread_Abort_Sleeping()
        {
            PollingThread thread;
            DateTime      start;

            arg   = null;
            count = 0;

            thread       = new PollingThread(TimeSpan.FromSeconds(0.1));
            thread.Poll += new MethodArg1Invoker(OnPollSleep);
            thread.Start(null);

            Thread.Sleep(1000);
            start = SysTime.Now;
            thread.Close(TimeSpan.FromSeconds(1));
            Assert.IsTrue(SysTime.Now - start <= TimeSpan.FromSeconds(1.1));
        }
コード例 #2
0
        public void PollingThread_Basic()
        {
            PollingThread thread;

            arg   = null;
            count = 0;

            thread       = new PollingThread(TimeSpan.FromSeconds(1));
            thread.Poll += new MethodArg1Invoker(OnPoll);
            thread.Start("Hello World");

            Thread.Sleep(5100);
            thread.Close(TimeSpan.FromSeconds(2));

            Assert.AreEqual(6, count);
            Assert.AreEqual("Hello World", arg);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: debdipto/Master-Remote
        public void setupConnection()
        {
            if (clientSocket != null)
                disconnect();

            displayLine("Client started");

            try
            {
                clientSocket = new TcpClient();
                displayLine("Checking IP address:" + EvergreenMasterRemote.Properties.Settings.Default.ServerIP);
                clientSocket.Connect(EvergreenMasterRemote.Properties.Settings.Default.ServerIP, 6669);
                displayLine("Server Connected");

                String status = writeToServer(EvergreenMasterRemote.Properties.Settings.Default.Username + ":" + EvergreenMasterRemote.Properties.Settings.Default.Password+"$$");
                //String status = readFromServer();
                displayLine(status);
                if (status == "OculusMessage:Authentication Failed$$")
                {
                    disconnect();
                    displayLine("Authentication Failed",true);
                    return;
                }                

                //getListOfClients();                

                pollingThread = new PollingThread(this, EvergreenMasterRemote.Properties.Settings.Default.Username, clientSocket);
                polling = new Thread(new ThreadStart(pollingThread.poll));
                polling.Start();
                this.Text = EvergreenMasterRemote.Properties.Settings.Default.Username;
                return;
            }
            catch (Exception)
            {
                displayLine("No server found in that IP");
            }

            displayLine("Server Not Found");
        }