C
C#2y ago
Eagle

✅ After 2 wrong guesses, the program closes immediately

As the title says, after 2 wrong guesses the program doesnt show the text, or wait 3000 milliseconds. It just closes immediately. I dont know if Environment.Exit is a correct command to use in this situation, i just looked it up. Basically, after 2 wrong guesses i want the program to wait 3 seconds and then close.
8 Replies
Kouhai
Kouhai2y ago
You're not awaiting Task.Delay
mindhardt
mindhardt2y ago
If you are a beginner you may use Thread.Sleep instead of Task.Delay. tho in actual apps it is a no-go, but I suggest to not weigh yourself with async/await for now
Eagle
EagleOP2y ago
okay, thank you. so there isnt any beginner-friendly way for the program to wait?
mindhardt
mindhardt2y ago
Thread.Sleep is simple but it blocks the thread, which will concern you only after you start creating multi-thread programs
Eagle
EagleOP2y ago
Okay, thanks, ill try to use thread.sleep and see how it goes ill be sure to change that after learning about these multi thread programs
mindhardt
mindhardt2y ago
You may as well do
Task.Delay(3000).RunSyncronously();
Task.Delay(3000).RunSyncronously();
Afair it will work the same way
Eagle
EagleOP2y ago
this gives me some errors, ill use the thread.sleep for now
mindhardt
mindhardt2y ago
Consider /closeing this thread
Want results from more Discord servers?
Add your server