private void GetDataAndUpdateConsolOutputBox() { while (running) { client.GetAutoResetEvent().WaitOne(); string str = client.GetData(); int size = str.Length; Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { tbConsole.Text = DateTime.Now.ToString("h:mm:ss tt") + " Server: " + str + tbConsole.Text; })); } }