Hi. I'm handling messages coming into a client application. When message a1 comes in, I want to get some information and display it onto a form MainForm. To handle the incoming messages from the server, I need a thread to do so. So here's what I did:

MainForm mf = new MainForm();
public void ServerThreadRunning()
{

// Get message from server.
// Proces message and get information

mf .txtMessage.Text = infoa
mf ........
// I dislpay the information onto the MainForm.

}


However I had to change this up since after displaying the information, the MainForm was sticking and then crashed. So what I did was to create another thread with the Server thread as:

MainForm mf = new MainForm();
public void ServerThreadRunning()
{

// Get message from server.
// Proces message and get information

// Instantiate new thread, subthread.

}

public void subthreadmethod()
{
mf .txtMessage.Text = infoa
mf ........
// I dislpay the information onto the MainForm.

}


Now this works fine. The MainForm is not sticking after displaying the message. however, it seems that when subthread ends, it disposes MainForm object so if I try to use mf in another part of the program, I'm getting error: object is not instantiated. So when this inner thread ends, it also terminates my object.

How could I solve this problem? How could I access and display my information from within the thread without that thread disposing my object?

Jennifer