Original Post
I'm using C#.Net in VS 2008.
I'm creating a Chat Messenger using form application.
A server is running and different users log in as clients and chat.
On the client side, two thread are running.
One is the main thread to display everything and call the event handlers.
The other one is for receiving the data from the server and take appropriate actions.
To take action, this thread parse the data received by the server (by calling another function), processes it.
Now, in the main Thread, I've created a listbox which stores the contacts received from the server.
But this is being updated from the second Thread.
It is running fine.
But while debugging, it gives a CrossThreadOperationException whenever it updates this listbox. It says that this listbox was not created in the Thread in which it is being used.
Tell me whether it is a good design to do so.
So many cross thread operations like that would be there.
Is it possible to share a string value between these two threads?
Whenever the second one updates the value of the string, some method is triggered from the first thread to parse and process it?
I'm creating a Chat Messenger using form application.
A server is running and different users log in as clients and chat.
On the client side, two thread are running.
One is the main thread to display everything and call the event handlers.
The other one is for receiving the data from the server and take appropriate actions.
To take action, this thread parse the data received by the server (by calling another function), processes it.
Now, in the main Thread, I've created a listbox which stores the contacts received from the server.
But this is being updated from the second Thread.
It is running fine.
But while debugging, it gives a CrossThreadOperationException whenever it updates this listbox. It says that this listbox was not created in the Thread in which it is being used.
Tell me whether it is a good design to do so.
So many cross thread operations like that would be there.
Is it possible to share a string value between these two threads?
Whenever the second one updates the value of the string, some method is triggered from the first thread to parse and process it?