join() timesout even though thread has completed

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

Hi,
I'd just like to know why, when a System.Threading.Timer timer is fired, and
I set a class variable to CurrentThread within the Timer method, that when
calling Join on that thread in a different thread, it times out even though
the Timer method has completed.
Do I need to explicitly create a new thread explicitly in the Timer method
being fired and join on that new thread instead? I would have imagined that
when the Timer goes off, a thread is created in the background and joining
on that thread would have worked.
Thanks.
Craig
 
Craig,

I believe the timer class fires an event on a thread from the thread
pool, which is why you won't see the thread die (it is being kept alive in
the pool).

If you are looking for a signal for when a task is complete, you should
not use the join method on the thread. Rather, you should set up an event
and wait on that.

Hope this helps.
 

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

Back
Top