Chris
Wed Feb 25 12:49:58 CST 2004
It's a damned good question, especially if the event handler needs to update
the UI. If it's in the context of the worker thread, the event handler
needs to call Control.Invoke, if it's in the primary thread context, then it
doesn't.
Your point that the thread that created the handler may no longer exist is a
good one, so I'm thinking now that you're probably right that it is in the
invoker's thread, not the creator's.
--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1aa6fc6958abb9a298a24b@msnews.microsoft.com...
> Chris Tacke, eMVP <ctacke@spamfree-opennetcf.org> wrote:
> > > I believe it's in the same thread, yes.
> >
> > Hmm, I would think the event handler would run in the thread that
created
> > the handler, not the event firer.
>
> How would that work? The thread that created the event handler may not
> even exist any more, and if it *does* exist it may well not be running
> anything like a message pump.
>
> > Bear in mind I've not tested it, but it's
> > a good question. Here's how I think (and agin, it's my thinking, which
is
> > often flawed):
> >
> > Given the code below, wouldn't the MEssageBox be running in the same
thread
> > as threadprocA, even though threadprocB raised it?
>
> Well, the MessageBox itself might be - I don't know exactly how
> MessageBoxes work in terms of threading, but it would be the thread
> running threadprocB which actually called MessageBox.Show.
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too