I have a toolbar control in my main form. I thread out a an instance of a
watcher class (just looking for new processes and raising an event when one
arises) as a background thread. my main form receives events from the
watcher thread.
Now, within the event handler on the main thread (which is firing just fine)
I attamept to add a new toolbar button to my toolbar based on the event
args. If I generate labels or standard form buttons everything is fine.
But if I try to add a button to a toolbar the program will seize up
(actually the toolbar control seems to lock up since it is the first item to
stop drawing itself). Sometimes I'll get a NullReference exception out of
the fiasco, other times I'll get a "Window handle already in use" error.
Neither of which make any sense given that everything is initialized and not
null, and all I am trying to do is add a button. If I do this identical
routine without threading out the watcher everything works fine.
The only difference between working versions and non-working is the
background thread approach.
Is this a bug?
Thanks!!