issues with timer class c#

Last post 07-02-2009 1:21 PM by MetalAsp.Net. 5 replies.

Sort Posts:

  • issues with timer class c#

    07-02-2009, 4:29 AM
    • Member
      1 point Member
    • danny_rome
    • Member since 07-02-2009, 8:22 AM
    • Posts 9

    hi everyone..you are my last hope :D

    I have a problem...I'd like to try to do this thing (i'll write it in a pseudo-code)

    (every 5 seconds){ do something}

    well as concerne the "do something" part I have already wrote the code. the big problem is how to use timer! I tryed this thing


    try{
    .....
    Timer timer = new Timer();
    timer.Interval = 5000;
    timer.Enabled=true;
    timer.Start();
    timer.Elapsed += delegate
    {
     String p = prestazioni[j].ToString();
                        Label2.Text = p;
                        if (j == (righe - 1))
                            j = 2;
                        gvdati.DataSource = elaboraQuery02(prestazioni, j);
                        gvdati.DataBind();
                        gvdati01.DataSource = elaboraQuery01(prestazioni, j);
                        gvdati01.DataBind();
                        gvdati02.DataSource = elaboraQuery(prestazioni, j);
                        gvdati02.DataBind();
                        j++;
                    };
    }
    catch...
    finally...

    the problem is that  after "timer.Start();" the code skip the delegate(I checked it with debug) and I don't know why...anyone can help me?

    If you think is better to change  the code and/or you have any hints you are more than welcome... help please :)

    bye bye

    daniele

  • Re: issues with timer class c#

    07-02-2009, 10:06 AM

    How about dragging a Timer control to your design view, and handling the Tick event, where you can put your code...

  • Re: issues with timer class c#

    07-02-2009, 11:34 AM
    • Member
      1 point Member
    • danny_rome
    • Member since 07-02-2009, 8:22 AM
    • Posts 9

    hem...I'm pretty new with c# and asp.net in general...can you make me an example of the code?  :P

  • Re: issues with timer class c#

    07-02-2009, 1:00 PM

    There's no code to show you.  Simply put the timer control in your design view, and double click on it to create the Tick handler.  Then you can put the code you currently have (whatever processing you want to achieve) in there.  It's that simple.

  • Re: issues with timer class c#

    07-02-2009, 1:05 PM
    • Member
      1 point Member
    • danny_rome
    • Member since 07-02-2009, 8:22 AM
    • Posts 9

    sorry for my ignorance....I work with c# and visual studio 2005(so framework 2.0)..so..is timer control available for my configuration?

    thank you for being so kind :)

  • Re: issues with timer class c#

    07-02-2009, 1:21 PM
    Answer

    Ah ok, I see.  I'm on VS 2008 and I see the control under the "AJAX Extensions" tab.  I can refer you to this page, but I don't know if downloading the Extensions 1.0 stuff will get you the Timer control.  I'll let you investigate and decide for yourself:

    http://www.asp.net/ajax/downloads/archive/

Page 1 of 1 (6 items)