It is necessary to suspend the program for some time in some place. I try to make it so that some time passes between the user's text and the output of the answer (question-time-answer), but when using Thread.Sleep (), the program falls asleep before outputting the question-answer (time-question-answer). Tell me how to do
static void sre_speech(object sender,SpeechRecognizedEventArgs e) { string answer="Извини, не поняла"; if (e.Result.Confidence > 0.82) {t.Text += "Ivan:>"+e.Result.Text+Environment.NewLine; switch (e.Result.Text) { case "Привет": answer = "Привет, Иван"; break; case "Как дела": answer = "У меня неплохо :)"; break; case "Сколько времени": answer = dt.Hour+":"+dt.Minute+":"+dt.Second; break; } } Thread.Sleep(1500); t.Text += "Caroline:>" + answer + Environment.NewLine; }` private void form1_Shown(object sender, EventArgs e) { t = chat; CultureInfo ci = new CultureInfo("ru-ru"); SpeechRecognitionEngine sre = new SpeechRecognitionEngine(ci); sre.SetInputToDefaultAudioDevice(); sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_speech); Choices words = new Choices(); words.Add(new string[] {"Привет","Как дела","Сколько времени" }); GrammarBuilder gb = new GrammarBuilder(); gb.Append(words); Grammar g = new Grammar(gb); sre.LoadGrammar(g); sre.RecognizeAsync(RecognizeMode.Multiple); }` A phrase is entered by the user (for example, it is asked how much time), and the answer should not be displayed immediately, after a while (as some kind of simulation of deliberation)

sre_speechis a kind of event handler for the application, andtis a text field , and it is not updated until the handler has completed. I guess? - yeputons