public static async Task Main()
        {
            SendThread.Start(CancellationToken.Token);
            RecieveThread.Start(CancellationToken.Token);

            Console.WriteLine("Welcome!  You can send anything to simulate a process or 'q' to quit");

            while (true)
            {
                string command = Console.ReadLine();

                if (command.ToLower() == "q")
                {
                    CancellationToken.Cancel();

                    SendThread.Join();
                    RecieveThread.Join();

                    CancellationToken.Dispose();

                    return;
                }

                Console.WriteLine(await SendData(command));
            }
        }
Example #2
0
        private void ReciveMessages(Stream networkStream)
        {
            var reader = new BinaryReader(networkStream);

            try
            {
                KeepReceivingMessages(reader);
            }
            finally
            {
                RecieveThread.Abort();
            }
        }