Home > Back-end >  How what waiting thread, director of the execution of the routine,
How what waiting thread, director of the execution of the routine,

Time:10-24

Main form is a cycle, first to start a thread, when the main window to check the thread finishes make edit1. Text:='1', into the next cycle, to start a thread, dangdang main form to check the thread finishes make edit1. Text:='2',
Question 1: how to make the main form know thread finished,
2: how to make the main form of execution of the thread to perform the next cycle,

I have no idea, all the big bird to give directions, had better have an example

CodePudding user response:

Delphi thread wait functions WaitForSingleObject baidu once,

CodePudding user response:

Upstairs, with the help of a wait function the thread synchronization, it is a way to write up a little bit complicated,

Another method is to keep the asynchronous state, defined in the child thread a TNotifyEvent event, the main thread with routines to monitor events, after the child thread execution activate this event, the main thread will be ready to take over control,

CodePudding user response:

Top 1/f,,,,,

CodePudding user response:

Although can use semaphore to do, but the main thread has been stuck in your cycle?
The asynchronous notification form line:
1, thread finish send a message to form
2, thread class set up an event functions, the Synchronize your event function call,

CodePudding user response:

A lot of kinds of methods can achieve
Semaphore
Events
Stay to resolve

CodePudding user response:

TThread CheckTerminated check

CodePudding user response:

The Synchronize