Custom Components, Threads, and Invoke

  • Thread starter Thread starter Wavemaker
  • Start date Start date
W

Wavemaker

I've created a custom component that is derived from the Component
class. This component can be added to a form. What I've noticed is
that I run into problems if I call methods on the component from a
different thread than the one in which it was created.

I'm aware that you should never access a windows form control from
another thread but should call the parent form's Invoke or
BeginInvoke methods passing them a delegate they can call that will
in turn access the control.

Does this apply to custom components as well?

If so, is this documented any where?
 
At the heart all windows apps still rely on the message pump to work. Since
the message pump is thread specifc any functionality which relies on
messages will need to be executed on the thread that has the message pump.
That is why the need arises to use Invoke() etc.
 
Back
Top