Exemplo n.º 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            while (!backgroundWorker1.CancellationPending)
            {
                object[] portAndListenerAndReply = e.Argument as object[];
                Int32    port = int.Parse(portAndListenerAndReply[0].ToString());

                chatListener = portAndListenerAndReply[1] as TCPListener;

                var incomingMessages = chatListener.Listen(port);
                foreach (string[] dataForUI in incomingMessages)
                {
                    worker.ReportProgress(1, dataForUI);
                }
            }
        }
Exemplo n.º 2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;


            while (!backgroundWorker1.CancellationPending)
            {
                Int32 port = int.Parse(e.Argument.ToString());
                worker.ReportProgress(0, "Stop listening");
                tCPListener = new TCPListener();

                var incomingConnections = tCPListener.Listen(port);
                foreach (string[] dataForUI in incomingConnections)
                {
                    worker.ReportProgress(1, dataForUI);
                }
            }
        }