
Signature
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
In the timer i'm running a thread
---
Thread Status = new Thread(statusJob);
Status.Start():
----
Peter Ritchie [C# MVP] pisze:
> What type of Timer are you using? If it's Windows.Forms.Timer you're not
> using a background thread.
>
> Maybe you can provide some detailed code of what you're doing in your
> Tick/Elapsed event handlers?
Peter Duniho - 19 Mar 2008 19:00 GMT
> In the timer i'm running a thread
>
> ---
> Thread Status = new Thread(statusJob);
> Status.Start():
> ----
Why are you doing that? If you need for the timer event to be handled on
a separate thread, then use Threading.Timer which already runs the timer
event code on a different thread (it uses a thread pool thread). Starting
a whole new thread every time the timer elapses is wasteful and
unnecessary.
As Peter R. said, you really ought to be more specific about what you're
doing. Without describing in detail what timer you're using, how you're
using it, and what your code does in response to the timer, it's
impossible to suggest what might be causing the issue you're seeing.
Pete
Peter Ritchie [C# MVP] - 19 Mar 2008 19:45 GMT
It's hard to say what the problem could be with such little to go on.
I agree with Peter though, spawning an new thread on ever Timer tick isn't
the most efficient method.

Signature
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
> In the timer i'm running a thread
>
[quoted text clipped - 9 lines]
> > Maybe you can provide some detailed code of what you're doing in your
> > Tick/Elapsed event handlers?
garther - 19 Mar 2008 21:03 GMT
So what method would you suggest for this purpose?
Peter Ritchie [C# MVP] pisze:
> It's hard to say what the problem could be with such little to go on.
>
> I agree with Peter though, spawning an new thread on ever Timer tick isn't
> the most efficient method.
Peter Duniho - 19 Mar 2008 23:35 GMT
> So what method would you suggest for this purpose?
Well, you haven't bothered to answer the questions asked you, including
"What type of Timer are you using?" The other relevant question asked but
not yet answered is "what are you doing in your elapsed event handlers?"
The only thing you've posted so far is code that suggests you're creating
a whole new thread every time the timer fires. From what little
information you've shared so far, it's impossible to tell you exactly how
to fix that, but it's pretty easy to know that it's almost certainly wrong
to do it the way you're doing it.
Pete