I have a main form with the UI, and a separate thread which will "safely" write messages to the UI.
The problem arises when the main form shuts down, its possible the thread has already started to write another message so it will cause an already disposed exception when it access the main form. I modified this so it checks if the main form has been disposed or not before it writes the message. Now however there is an even rarer condition where the main form is disposed between the thread checking that the main form has not been disposed and writing the message.
Question
spike232
I have a main form with the UI, and a separate thread which will "safely" write messages to the UI.
The problem arises when the main form shuts down, its possible the thread has already started to write another message so it will cause an already disposed exception when it access the main form. I modified this so it checks if the main form has been disposed or not before it writes the message. Now however there is an even rarer condition where the main form is disposed between the thread checking that the main form has not been disposed and writing the message.
Is there anyway round this?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts