Multithreading in WPF application
<p>I want processing data in a thread and, at the same time, maintaining the control on the UI.
In my program, when i click on a "Connect" button, client is connected to a server through a socket, but at the same time i would to start a thread that continuously waits for a message from the server.
My code is approxymately:</p>

<pre><code>Thread ListenThread;
SocketClient socket = new SocketClient();

        public MainWindow()
        {
            ListenThread = new Thread(Wait);
            InitializeComponent();
            socket.StartClient(PORT);
        }

private void CONNECT_Click(object sender, RoutedEventArgs e)
        {
            socket.Connect();
            UpdateUI();
            ListenThread.Start();
        }

private void Wait (){
            while (socket.isConnected())
                socket.WaitForSomething();
        }

private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            HandlePressure(e.Key);
        }
</code></pre>

<p>The problem is that, when I start <code>ListenThread</code>, I can't use UI (I have a textbox that collects commands that I must send to the server).
How I can handle this situation?
Thanks.</p>