R
Ron James
I have a Form based dialog which kicks off a worker
thread. The form has a progress bar, and a Cancel
button. The Cancel button Aborts the thread, and when
exiting, the thread attempts to Show a hidden control on
the form. This does not work, and I'm pretty sure it's
because the Show method is being called from a different
thread. Closer inspection of the documentation for Form
and the various controls confirms this. (Static members
are threadsafe, but instance members are not).
The worker thread also updates the progress bar directly
on the Dialog, and athough this is working, I now believe
that I shouldn't be doing this. Am I correct?
In the C++ world, I would have posted a user message to
the form, but I can't find anything similar in .NET.
How can I update by Dialog from the worket thread in a
threadsafe manner.
Thanks
thread. The form has a progress bar, and a Cancel
button. The Cancel button Aborts the thread, and when
exiting, the thread attempts to Show a hidden control on
the form. This does not work, and I'm pretty sure it's
because the Show method is being called from a different
thread. Closer inspection of the documentation for Form
and the various controls confirms this. (Static members
are threadsafe, but instance members are not).
The worker thread also updates the progress bar directly
on the Dialog, and athough this is working, I now believe
that I shouldn't be doing this. Am I correct?
In the C++ world, I would have posted a user message to
the form, but I can't find anything similar in .NET.
How can I update by Dialog from the worket thread in a
threadsafe manner.
Thanks