Timer Question

Discussion in 'ASP .Net' started by =?Utf-8?B?UmljaGFyZCBTdGVlbGUgKEJhc2VtYXAp?=, Dec 1, 2005.

  1. Hi
    In ASP.net (c#) I want to be able to send a request to a user i.e. flag a
    status (lets say for example you have a
    job allocated to you) and then if they have not acknowledged the job within
    a set period of time i.e. 1 hour
    that job is then reallocated to someone else. I guess i would add a row to
    my DB table with a time stamp and then
    1 hour later reallocate the job

    I am using MySQL so timed triggers may not be a possibility, would this be
    done as a windows service
    where every n secs i scan the table comparing the time with the server time
    and search for records with
    the time equal to +1 hour?

    Any suggestions would be gratefully appreciated

    --
    Thanks
    Richard
     
    =?Utf-8?B?UmljaGFyZCBTdGVlbGUgKEJhc2VtYXAp?=, Dec 1, 2005
    #1
    1. Advertising

  2. You can use another thread

    public class IndexerSchedule
    {
    public static void Install(int interval)
    {
    ThreadStart myThreadDelegate = new
    ThreadStart(IndexerSchedule.run);
    Thread myThread = new Thread(myThreadDelegate);
    myThread.Name = interval.ToString();
    myThread.Start();
    }

    private static void run()
    {
    int interval = 0;
    interval =
    System.Convert.ToInt32(Thread.CurrentThread.Name);
    if (interval>0)
    {
    while(true)
    {
    //Do what you want

    // Pause Thread
    Thread.Sleep(interval*1000);
    }
    }
    }
    }

    --
    Daniel Fisher(lennybacon)
    http://www.lennybacon.com


    "Richard Steele (Basemap)" <>
    wrote in message news:...
    > Hi
    > In ASP.net (c#) I want to be able to send a request to a user i.e. flag a
    > status (lets say for example you have a
    > job allocated to you) and then if they have not acknowledged the job
    > within
    > a set period of time i.e. 1 hour
    > that job is then reallocated to someone else. I guess i would add a row
    > to
    > my DB table with a time stamp and then
    > 1 hour later reallocate the job
    >
    > I am using MySQL so timed triggers may not be a possibility, would this be
    > done as a windows service
    > where every n secs i scan the table comparing the time with the server
    > time
    > and search for records with
    > the time equal to +1 hour?
    >
    > Any suggestions would be gratefully appreciated
    >
    > --
    > Thanks
    > Richard
     
    Daniel Fisher\(lennybacon\), Dec 1, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?UmljaGFyZCBTdGVlbGUgKEJhc2VtYXAp?=

    Scott Allen Guest

    Hi Richard:

    I'd go with either a Windows Service, or even easier is to set up a
    scheduled task in Windows. You can write a console mode application
    that runs every x minutes and queries the database for jobs to
    maintain.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Thu, 1 Dec 2005 02:59:02 -0800, Richard Steele (Basemap)
    <> wrote:

    >Hi
    >In ASP.net (c#) I want to be able to send a request to a user i.e. flag a
    >status (lets say for example you have a
    >job allocated to you) and then if they have not acknowledged the job within
    >a set period of time i.e. 1 hour
    >that job is then reallocated to someone else. I guess i would add a row to
    >my DB table with a time stamp and then
    >1 hour later reallocate the job
    >
    >I am using MySQL so timed triggers may not be a possibility, would this be
    >done as a windows service
    >where every n secs i scan the table comparing the time with the server time
    >and search for records with
    >the time equal to +1 hour?
    >
    >Any suggestions would be gratefully appreciated
     
    Scott Allen, Dec 1, 2005
    #3
  4. =?Utf-8?B?UmljaGFyZCBTdGVlbGUgKEJhc2VtYXAp?=

    Scott Allen Guest

    It's not scalable if you are creating a thread per user - threads are
    precious.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Thu, 1 Dec 2005 12:18:26 +0100, "Daniel Fisher\(lennybacon\)"
    <> wrote:

    >You can use another thread
    >
    > public class IndexerSchedule
    > {
    > public static void Install(int interval)
    > {
    > ThreadStart myThreadDelegate = new
    >ThreadStart(IndexerSchedule.run);
    > Thread myThread = new Thread(myThreadDelegate);
    > myThread.Name = interval.ToString();
    > myThread.Start();
    > }
    >
    > private static void run()
    > {
    > int interval = 0;
    > interval =
    >System.Convert.ToInt32(Thread.CurrentThread.Name);
    > if (interval>0)
    > {
    > while(true)
    > {
    > //Do what you want
    >
    > // Pause Thread
    > Thread.Sleep(interval*1000);
    > }
    > }
    > }
    > }
     
    Scott Allen, Dec 1, 2005
    #4
  5. Thanks Scott, i'll write some test code and see how it goes
    --
    Thanks
    Richard


    "Scott Allen" wrote:

    > Hi Richard:
    >
    > I'd go with either a Windows Service, or even easier is to set up a
    > scheduled task in Windows. You can write a console mode application
    > that runs every x minutes and queries the database for jobs to
    > maintain.
    >
    > --
    > Scott
    > http://www.OdeToCode.com/blogs/scott/
    >
    > On Thu, 1 Dec 2005 02:59:02 -0800, Richard Steele (Basemap)
    > <> wrote:
    >
    > >Hi
    > >In ASP.net (c#) I want to be able to send a request to a user i.e. flag a
    > >status (lets say for example you have a
    > >job allocated to you) and then if they have not acknowledged the job within
    > >a set period of time i.e. 1 hour
    > >that job is then reallocated to someone else. I guess i would add a row to
    > >my DB table with a time stamp and then
    > >1 hour later reallocate the job
    > >
    > >I am using MySQL so timed triggers may not be a possibility, would this be
    > >done as a windows service
    > >where every n secs i scan the table comparing the time with the server time
    > >and search for records with
    > >the time equal to +1 hour?
    > >
    > >Any suggestions would be gratefully appreciated

    >
    >
     
    =?Utf-8?B?UmljaGFyZCBTdGVlbGU=?=, Dec 2, 2005
    #5
    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. =?Utf-8?B?UHVtcGtpbg==?=

    A question about timer

    =?Utf-8?B?UHVtcGtpbg==?=, Aug 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    460
    =?Utf-8?B?UHVtcGtpbg==?=
    Aug 18, 2005
  2. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    718
    Kelsang Wangchuk
    Jul 31, 2003
  3. Replies:
    1
    Views:
    1,614
    Steve C. Orr [MVP, MCSD]
    Feb 22, 2005
  4. Simon

    page timer, or redirect timer

    Simon, Nov 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    11,213
    Bruce Barker
    Nov 4, 2005
  5. Replies:
    8
    Views:
    511
    Jorgen Grahn
    Jul 15, 2013
Loading...

Share This Page