Don't use thread.sleep - particularly not in your normal (or UI thread). It stops the whole thread from doing anything, and thus the system from responding to the user inputs...
Probably what you want to do is use a Timer and do your conditional processing in the Tick event - but without seeing your code, it's not possible to be any more precise.
"i hope i make my point cause i don't have a better way to explain it."
I must admit - that code doesn't make a whole lot of sense! :laugh:
Ignoring that it won't compile as a code fragment - there is a close curly bracket above the "continue" label that isn't matched in the code fragment, so I don't know how relevant it is.
The first thing to do is remove that label, and then remove the word "goto" from your memory. As a beginner, if you have to use "goto" and labels in your code, then you have done something very, very wrong! I haven't used it once since I learned C#, simply because I haven't needed it. You shouldn't either. ;)
I am assuming that what you are trying to do is put a delay between the first bit and the second?
OK - lets do it. Firstly, let's tidy up your code a little. Replace the code above the "continue" with this:
if (textBox1.Text != "")
{
textBox2.Text += textBox1.Text + "\r\n";
}
Visually to the user it does the same thing as your code.
Then, let's do something really silly...let's throw your code away...:laugh:
Instead, let's create a couple of class level variables:
private int waitTimer = 0;
private string waitMessage = "";
and then let's tidy up your other code and use these instead.
if (textBox1.Text.ToLower() == "what are you?")
{
waitMessage = "I am a computerized robot and my name is Dr. A";
waitTimer = 4;
}
textBox1.Clear();
What this does is pretty obvious, except for the first part - which converts all the uppercase characters in the textbox to lower case and then checks them. This means that you don't have to type the string loads of times, and get it wrong occasionally, and the user can type it all in uppercase if he is feeling angry!
But that does nothing to the display - so use the Timer code I gave you before, and put this in the Tick event handler:
if (waitTimer > 0)
{
if (--waitTimer == 0)
{
textBox2.Text += waitMessage + "\r\n";
}
}
The value "4" in the waitTimer is supposed to match with the "250" I put in the Interval property of the Timer, to give about one second. Larger numbers will make the delay longer, smaller will make it shorter.
Now try it!