| |

VerySource

 Forgot password?
 Register
Search
View: 1044|Reply: 6

No way for custom threads to sleep?

[Copy link]

4

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-3 22:40:01
| Show all posts |Read mode
I want to pause a custom thread for 5 seconds, how to do it
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-3 23:03:01
| Show all posts
Thread.Sleep () is sleeping on the current thread
Reply

Use magic Report

0

Threads

17

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-4 03:39:01
| Show all posts
Thread sThead = new ....

sThread.Sleep (5000);

Is there a way to do this?
Reply

Use magic Report

4

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-4 07:45:01
| Show all posts
I use the MDI form. When the child form Thread executes sleep, all the forms stop, as if this method does not work.
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-1-4 08:15:01
| Show all posts
try ...

Application.DoEvents ();
Reply

Use magic Report

4

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-18 17:00:01
| Show all posts
Below your own top, Application.DoEvents () just makes the window active, and actually does not sleep
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-20 11:36:02
| Show all posts
Pause the current thread for a few seconds, and the system executes other threads
Delay (3);

 #region delay (in seconds)
        public void Delay (int delayTime)
        {
            DateTime now = DateTime.Now;
            int s;
            do
            {
                TimeSpan spand = DateTime.Now-now;
                s = spand.Seconds;
                Application.DoEvents ();
            }
            while (s <delayTime);
        }
        #endregion
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list