c#:
You have to check the InvokeRequired property of your Toolbar control to make
sure you don't
need to call Invoke to get the call on the primary UI thread. In your case you
think the the main
thread is handling the event you toss, but it probably isn't. you are probably
still on the watcher thread.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog:
http://weblogs.asp.net/justin_rogers [quoted text, click to view] "Sean Dudley" <dudleys@uwplatt.edu> wrote in message
news:eWbqeix3DHA.488@TK2MSFTNGP12.phx.gbl...
> 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!!
>
>