Re: when is threading better than a timer?

From: Bob (noone_at_nowhere.com)
Date: 09/29/04


Date: Wed, 29 Sep 2004 10:36:24 -0400

It's milliseconds. Looks like I was using the right Timer class, too
(System.Windows.Forms.Timer), since I wanted it to mesh with and respect the
UI. Very good links, thank you.

Bob

"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:OF807%23ipEHA.3172@TK2MSFTNGP10.phx.gbl...
> Bob,
> If you have a long running process (half a minute or longer) I would
> recommend a separate thread. By long running, I mean if it takes long
enough
> that the user will start to think your app stopped responding (hung).
>
> If the database check takes fractions of a second I would leave it as a
> Windows Timer.
>
> Remember there are three distinct timer objects in .NET. One of the other
> two may be more appropriate, the following articles in MSDN Magazine
explain
> the difference between the three timer objects in .NET & when to use each.
>
> http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx
>
> http://msdn.microsoft.com/msdnmag/issues/04/03/default.aspx
>
> The above articles also discusses if & how each timer interacts with
> threading.
>
> Hope this helps
> Jay
>
>
> Hope this helps
> Jay
>
> "Bob" <noone@nowhere.com> wrote in message
> news:ei6CKhipEHA.3520@TK2MSFTNGP11.phx.gbl...
> > Okay, I've done this for years but now I'm going to question it just
> > because
> > this idea has been at the back of my head since I started using
DotNet...
> >
> > My WinForms app queries a database every 60 seconds. I set up a
singleton
> > class that's instantiated when the app starts, and that starts a timer.
My
> > question is, would it be better to run this checking process on a
separate
> > thread and have it use its own DB connection? If there isn't a clear yes
> > or
> > no, what circumstances affect the answer?
> >
> > TIA,
> > Bob
> >
> >
>
>



Relevant Pages

  • Re: Lahman, how ya doing?
    ... >> I'd started with a Timer class that keeps the total time separately in ... double event job I wound up rewriting a few member functions in the ... derived class identically except for different pointer types. ...
    (comp.object)
  • POSIX based Timer class, occasional crash
    ... I've got a Timer class and a TimerClient base class. ... number of times to fire the timer, timer attributes, a pointer to the ... client, and a pointer to a client specific "payload" that gets ...
    (comp.unix.programmer)
  • Re: Timers
    ... so do i set the interval to x amount of milliseconds based on milliseconds ... It seems to me your best bet is to determine the exact time in the future you want the timer to execute, calculate the difference between that exact time and "now", and then use the result of that as the timer delay for a one-shot timer. ... It will fire when the elapsed time has expired. ... Each timer class has a slightly different syntax for configuring it as a one-shot timer, so without knowing what class you're using, it's not possible to say for sure what you would want to do. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: POSIX based Timer class, occasional crash
    ... > I've got a Timer class and a TimerClient base class. ... > Every once in a while an application that is using the timer crashes, ...
    (comp.unix.programmer)
  • Re: thread differences from button_Click and timer_Elapsed
    ... it would be the timer that uses a different thread (it ... but rather get one from the thread pool). ... does that depends on which timer class you're using. ... compare them between the two executions ...
    (microsoft.public.dotnet.framework)