Re: thread differences from button_Click and timer_Elapsed
- From: "Victor Reboucas" <vcreb@xxxxxxxxxxx>
- Date: Tue, 22 May 2007 21:55:51 -0300
Hi Pete,
Thanks a lot for your help... it just solved my problem!!!
I was using system.timers.timer and just changing that to forms.timer solved
the problem.
Thanks a lot,
Regards
Victor
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.tsq71ka28jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Tue, 22 May 2007 17:20:19 -0700, Victor Reboucas <vcreb@xxxxxxxxxxx>
wrote:
[...]
The question is: what is different in calling a method in a button click
routine and in a timer elapsed event (in threads meaning), is that the
"user interaction" (button click) that creates a new thread
automatically or sth like that?
If anything, it would be the timer that uses a different thread (it
wouldn't create it, but rather get one from the thread pool). Whether it
does that depends on which timer class you're using. The Forms.Timer
signals the timer event on the same thread as the form, but the other
timers don't. Your button's click event will run on the form's thread,
which is the main UI thread (unless you've done something specific to
change that).
That should be enough information to tell you what's going on, but if you
really want to check to see whether the two techniques wind up running on
different threads, you can get the Thread.ManagedThreadId property and
compare them between the two executions (in the same process, of course).
If the number is different, then one of the methods is using a different
thread than the other.
It does sound as though you're not using the Forms.Timer class, and that
the timer-based method does execute on a different thread. I suspect that
the main thing is that COM hasn't been initialized (or hasn't been
initialized properly for your use of DirectShow) on the timer thread, but
I don't have much in the way of specifics as to how you'd do that. If
you're using a timer that's using a thread pool thread, then you never
know which thread is actually going to be used. You are probably better
off either dedicating a thread to your timing somehow, or using Invoke()
to put the processing back on the main thread.
Pete
.
- References:
- thread differences from button_Click and timer_Elapsed
- From: Victor Reboucas
- Re: thread differences from button_Click and timer_Elapsed
- From: Peter Duniho
- thread differences from button_Click and timer_Elapsed
- Prev by Date: RE: Number formating is incorrect for "ar-LY" culture
- Next by Date: how do you run aspnet_regiss?
- Previous by thread: Re: thread differences from button_Click and timer_Elapsed
- Next by thread: RE: Number formating is incorrect for "ar-LY" culture
- Index(es):
Relevant Pages
|