C# Slowing a Loop
in this c# tutorial we will see how to make a Slowing a Loop and increase the time difference using C# components used "ListeBox"and "timer".
Project Source Code :
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 csharp_slowing_a_boucle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i = -1;
private void button1_Click(object sender, EventArgs e)
{
//int j = 0;
//while (j < listBox1.Items.Count)
//{
// listBox2.Items.Add(listBox1.Items[j].ToString());
// j++;
//}
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
i++;
if (i >= listBox1.Items.Count)
timer1.Stop();
else
{
listBox2.Items.Add(listBox1.Items[i].ToString());
timer1.Interval += 20;
}
}
}
}
Download Projects Source Code