I am working with two timers:
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 an output like this:
firsttimer:1
secondTimer:1
secondTimer:2
secondTimer:3
secondTimer:4
firsttimer:2
in message box.
But when debugging, debug cannot move in that order. After finished the secondtimer:2 it goes back to first timer. But I need to debug in the same order like without breakpoints.
I need for this in another application. Why does this happen?