how the get estimated output in timer
Posted
by ratty
on Stack Overflow
See other posts from Stack Overflow
or by ratty
Published on 2010-06-09T11:47:21Z
Indexed on
2010/06/09
12:12 UTC
Read the original article
Hit count: 161
i have working with twp timer,the code below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace example
{
public partial class Form1 : Form
{
int i = 0;
int j = 0;
public Form1()
{
InitializeComponent();
timer1.Interval = 3000;
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
i++;
timer2.Enabled = true;
if (i < 3)
time1(i);
else
timer1.Enabled = false;
}
private void timer2_Tick(object sender, EventArgs e)
{
j++;
timer2.Interval = timer1.Interval / 5;
if (j < 5)
time2(j);
else
timer2.Enabled = false;
}
private void time1(int i)
{
MessageBox.Show(i.ToString(), "First Timer");
}
private void time2(int j)
{
MessageBox.Show(j.ToString(), "SecondTimer");
}
}
}
when running this program it gives output like this firsttimer:1 secondTimer:1 secondTimer:2 secondTimer:3 secondTimer:4 firsttimer:2
in message box but when debugging debug cannot move that order.after finisheg the secondtimer:2 it gose back to first timer. but i need to go for how i am output get i need for this in another application. why it occurs
© Stack Overflow or respective owner