I am a Fresher, am creating a windows application in which i should have two timers(one is also Fine).
First timer starts on form loads and counts from 15 mins, 0(Zero) Secs to 0(Zero) Mins, 0(Zero) Secs.
Now Second timer should start counting and i want save the second timer data in server.
Please Help!!
Thank you,
VulpesPosted Mar 11, 2014, 2:42 PM
VulpesPosted Mar 13, 2014, 5:56 AM
VulpesPosted Mar 13, 2014, 5:49 AM
Brijendra GautamPosted Mar 13, 2014, 5:48 AM
const int MAX_Time = 15 * 60;
int interval = 1000;
int timerCount = MAX_Time;
bool countdown = true;
public Form1()
{
InitializeComponent();
timer1.Interval = interval;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (countdown) // Count Down
{
timerCount--;
}
else //Count Up
{
timerCount++;
}
if (timerCount == 0)
countdown = false; // Change the counter direction: count up
else if (timerCount == MAX_Time)
{
timer1.Stop(); // Stop the timer
//countdown = true; // Change the counter direction: count down
}
ShowRemainingTime();
}
private void ShowRemainingTime()
{
int mins = timerCount / 60;
int secs = timerCount % 60;
txtTest.Text = String.Format("{0:D2} : {1:D2}", mins, secs);
}
Hope this is helpful for you.
Narender ReddyPosted Mar 13, 2014, 3:28 AM
There was a small misunderstanding...
It worked well for first 15mins and after reaching 0mins, 0secs.
It started again to count from 15mins.
But my question was after Counting first 15mins i.e after reaching 00:00, it should count up.
I mean
00:00
00:01
00:02....so on.
anyway it helped me up to some extent...
Thank you once again.