Below is my simple code and I'm just curious why the statement " richTextBox1.AppendText("\nEnd of Contrustor");" is executed before the time starts. I would like it to execute after the timer ends, can anyone help me?
thanks.
Code:public Form1() { InitializeComponent(); call_searchFile(); richTextBox1.AppendText("\nEnd of Contrustor"); } private void call_searchFile() { richTextBox1.AppendText("Calling to search_file()"); search_File(); if(fileFound== true) richTextBox1.AppendText("\nFinish search file, do next task"); } private void search_File() { //Using Windows.Forms Timer. WindowFormTime = new System.Windows.Forms.Timer(); WindowFormTime.Enabled = true; WindowFormTime.Tick += new EventHandler(time_Tick); WindowFormTime.Interval = 2000; } void time_Tick(object sender, EventArgs e) { count++; if (File.Exists(textFile)) { fileFound = true; WindowFormTime.Enabled = false; richTextBox1.AppendText("\nWindow Timer: File found! " + count + " " + textFile); WindowFormTime.Stop(); } else { richTextBox1.AppendText("\nFile Not found! " + count); } }




Reply With Quote