| |

VerySource

 Forgot password?
 Register
Search
View: 1036|Reply: 4

BCB multithreading problem

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-25 18:40:01
| Show all posts |Read mode
The main form OnShow opened a TThread child thread, in the child thread
            while (! StopRunning)
            {
                :: Sleep (50);
                Application-> ProcessMessages ();
            }
If you don't add Application-> ProcessMessages () ;, the program will die. Why?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-15 07:15:01
| Show all posts
I added a new form in front of while, but it didn't show. If the form is not new, then Application-> ProcessMessages (); will not be added.
What is the reason for the master's explanation, thank you
Reply

Use magic Report

0

Threads

12

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-2-16 14:00:01
| Show all posts
Application-> ProcessMessages ();
Is to enable your code to process messages in the message queue.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-17 12:45:01
| Show all posts
But the main thread should not die. I loop while in the child thread. I tried if the form is not created in that child thread, the main thread will not die without Application-> ProcessMessages ()
Reply

Use magic Report

0

Threads

14

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-6 10:45:01
| Show all posts
Application-> ProcessMessages () is to let the main process accept new messages, but multithreading is to allow each thread to work independently. I think there is a problem with the multithreading design of the year.
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