Answer the question
In order to leave comments, you need to log in
Why is the thread blocking so strangely?
Faced a problem. The stream somehow strangely is blocked. The code is like this:
LambdaMechanism Mech = new LambdaMechanism(Angle, Radius);
Mech.Draw(canvas);
Thread.Sleep(TimeSpan.FromSeconds(3));
MessageBox.Show("Yes");
Task.Delay(3000).ContinueWith(_ => MessageBox.Show("Yes"))
But that option doesn't work for me. It is necessary to "stop" the execution of the code for 3 seconds
Answer the question
In order to leave comments, you need to log in
You are putting UIThread to sleep.
And you can't do that.
You will have to create a new thread and stop it for 3 seconds, then output Yes.
LambdaMechanism Mech = new LambdaMechanism(Angle, Radius);
Mech.Draw(canvas);
new Thread(()=>
{
Thread.Sleep(TimeSpan.FromSeconds(3));
MessageBox.Show("Yes");
}).Start();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question