Custom Components, Threads, and Invoke

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?
 
S

Sijin Joseph

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top