Exemplo n.º 1
0
        public static void ClassInit(TestContext context)
        {
            // run server and client on 2 threads to simulate real world and enable bi-directinal comuncation
            context.WriteLine("$$$$$$$$$$$$$$$$$$$$$$$$$$ Class Init");
            // context.CurrentTestOutcome

            Task task1 = new Task(() =>
            {
                mMyGingerServer = new MyGingerServer();
                mMyGingerServer.Start();
            });

            task1.Start();

            Thread.Sleep(2000);

            Task task2 = new Task(() =>
            {
                mMyGingerClient = new MyGingerClient();
                mMyGingerClient.Connect();
            });

            task2.Start();

            Thread.Sleep(500);
        }
Exemplo n.º 2
0
        public static void ClassInit(TestContext context)
        {
            // run server and client on 2 threads to simulate real world and enable bi-directinal comuncation

            Task task1 = new Task(() =>
            {
                mMyGingerServer = new MyGingerServer();
                mMyGingerServer.Start();
            });

            task1.Start();

            Stopwatch stopwatch = Stopwatch.StartNew();

            while ((mMyGingerServer == null || !mMyGingerServer.IsReady) && stopwatch.ElapsedMilliseconds < 5000)
            {
                Thread.Sleep(100);
            }
            if (!mMyGingerServer.IsReady)
            {
                throw new Exception("Error: mMyGingerServer.IsReady false");
            }


            Task task2 = new Task(() =>
            {
                mMyGingerClient = new MyGingerClient();
                mMyGingerClient.Connect();
            });

            task2.Start();

            Stopwatch stopwatch2 = Stopwatch.StartNew();

            while ((mMyGingerClient == null || !mMyGingerClient.IsReady) && stopwatch2.ElapsedMilliseconds < 5000)
            {
                Thread.Sleep(100);
            }
            if (!mMyGingerClient.IsReady)
            {
                throw new Exception("Error: mMyGingerClient.IsReady false");
            }
        }