I tried to make simple brute force algorithm.It s working normal.But I was watching this video
http://www.youtube.com/watch?v=v2xwficgRYk&feature=relmfu
(time 10:30) as you can see in textbox2 posibilities changes .But in my program.I create 1323 as a password and then when i click brute i waited 5 second and get 99999 in textbox2 and 1323 in textbox3.Why i cant see the flow of number in textbox2 like on video?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int a, b;
private void button1_Click(object sender, EventArgs e)
{
a = Convert.ToInt16(textBox1.Text);
}
private void button2_Click_1(object sender, EventArgs e)
{
for (int i = 0; i < 100000; i++)
{
textBox2.Text = "" + i;
if (a == i) textBox3.Text = "" + i;
}
}
}
That’s because the program in the video is running the brute force loop in a separate thread.
In your program the loop runs in the main thread, so as long as it’s running there is no thread watching the message pump where all the user interface updates happen.
Whenever the
Textproperty of the text box is changed there is a message dropped in the message queue that the text box needs to be redrawn to show the value, but the main thread is busy running the loop and won’t act on the messages until the loop is done.