do something till x minutes after running the program

How can I do something till 10 minutes after running my program

For example I want to show a messagebox 10 minutes later running my program.

And I want to show the time left to show that messagebox in a lable . for example I want to see "4" in that lable when 4 minutes remain to show that messagebox.



Answer this question

do something till x minutes after running the program

  • izadyas

    Hi,

    Add a timer control on the form and an interger class variable.

    No set the timer interval to 60000 (i.e. 1 Minute)

    And set the integer value to the minute you want to wait..

    For example ...  

    int TimeLeft=12;

    On each timer tick event

    if(TimeLeft>0)
    {

      timer.Enabled =flase;

      //do other stuff

    MessageBox.show("Your Time is Over!!!!!!")

    }
    else

    {

       TimeLeft--;

       label1.text= "Total Time Left"+TimeLeft;
    }

    Hope this help.



  • Jana Carter

    It doesn't work .I think it's because I dont know how can I add a timer.
    I need more help please .

  • Mark-Allen

    Hi,

    Ok, here is detail...

    Open the form on which you want to show the time remaining.

    Go to the Toolbox at left side of the visual studio.
    Go to the All Windows Forms Section...
    You will find here control with name "Label" control and also control with name "Timer"

    drage these control to the form one by one and dobule click on the timer there you can write the code for ticke event as i said earlier.

    Hope this helps.



  • GazCoder

    I founded my problem. It was about something else. But thanks a lot for your answer.


  • do something till x minutes after running the program