Re: long-running background threads

Discussion in 'ASP .Net' started by bruce barker, Jun 7, 2004.

  1. bruce barker

    bruce barker Guest

    as others have stated there is no trouble with long running thread, yours
    must be aborting.

    but is you added a last modified timestamp, you could code this without any
    threads.

    -- bruce (sqlwork.com)


    "Erik Sargent" <> wrote in message
    news:...
    > I have a very simple web app for displaying the status of a group of

    doctors (available/not available) which, purposefully, does not use a
    database. The status is stored as a private static variable of type
    AdmitStatus (an enum of the 3 possible values, plus a default.)
    > private static AdmitStatus _status;
    > (you access _status through a static property, which checks that it hasn't

    reset to the default value - and if it has, it reads the value from a text
    file which is there for persistence.)
    >
    > Now for the fun part! The docs want the status to reset to "open" for each

    shift change. So, Application_Start calls a static method "StartResetTimer",
    which spins off a new thread. That thread sleeps for a minute, checks the
    time versus the shift start times and goes back to sleep for a minute. If
    the current time matches a shift start, it calls back to a method to change
    the AdmitStatus _status back to "Open".
    >
    > When I debug, it works fine. When I make a request once per minute, it

    works fine. Each change is logged and I can pull up Windows explorer and
    watch the log file's timestamp increment each minute. The problem is if
    nothing happens for several minutes - then it just seems to stop.
    >
    > Now, I was thinking that if the thread were spun off from a Request thread

    that maybe this makes sense. But since it is spun off from the
    Application_Start even, I was hoping it would stay alive - just as the
    static variables that I am using maintain their state properly between
    requests. But maybe that thinking is wrong?
    >
    > Any suggestions of what to look for or how to fix the problem? (Or even

    what the problem is down at the IIS/ASP/CLR level?)
    >
    > p.s. I am sure that I could fix this by using a database or a Windows

    service and checking for a shift change there, but that is a lot of support
    and deployment overhead for what otherwise amounts to two web pages (display
    and admin). I also tried storing status in an Application scope variable,
    rather than in a static - but the thread didn't have access to it (in fact
    it reports HttpContext.Current == null, which I also found strange, but I'm
    fairly naive about multi-threading to begin with, so ...) At any rate, using
    Application or static wouldn't change the fact that my thread seems to stop.
    >
    >
    >
     
    bruce barker, Jun 7, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Browne

    Re: long-running background threads

    David Browne, Jun 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    361
    David Browne
    Jun 7, 2004
  2. iksrazal
    Replies:
    1
    Views:
    2,775
    marcus
    Jul 28, 2004
  3. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    709
    Eric Sosman
    Jul 8, 2003
  4. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,223
    Peter Shaggy Haywood
    Sep 20, 2005
  5. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    497
    santosh
    Jul 24, 2007
Loading...

Share This Page