Top.Mail.Ru Yandeks.Metrika
Forum: "WinAPI";
Current archive: 2004.12.12;
Download: [xml.tar.bz2];


Create and end stream Find similar branches

S@shka ©   (2004-10-30 23:45) [0]

People, here help me to finally enter the next question.
There is a window application, on Form.Create it is worth creating a stream
by calling BeginThread (...);
Further, as I understand it, let's say the thread has completed its work
we notified the main window, for example, PostMessage (Form1.Handle ...).
In the handler, call CloseHandle (ThreadHandle); And everything is ok.
And what to do if it is implied that the flow should work all the time (along with the application) and its completion will be only at the completion of the entire application. Do I have to wait on the flow execution on FormClose? (for example, using mutex). Is it enough just to inform the flow that it will be closed by setting a certain flag?
I quote (Delphi Rei Lishner Handbook) "When a form closes it interrupts the flow. It is possible that the message on the completion of the flow (if the flow on exit, after analyzing the completion flag set by FormClose is PostMessage form) will come after the destruction of the form, but it will not big problem since Windows will destroy the thread when the program ends. " And if some objects will be created in my flow function, will they be correctly destroyed in this case ??? unclear? or if the code for such a plan ...
function ThreadFunc ();
T: TMyObject;
T: = TMyObject.Create;
while (TRUE) do
sleep (20000);
T. Free;
PostMessage (Form1.Handle, WM_FINISHED, 0,0);
Is the destruction guaranteed T ??? and whether such code will come to a possible application hangs on closing for a time before 20 seconds ???
Thank you!

MaxDDinc   (2004-10-31 00:12) [1]

Any program objects, including threads (processes), will be destroyed when the main window is closed. The delay in the thread will not cause the program to hang, since it is separate from the main thread, which is allocated its own quantum of time to solve its own problems

Pages: 1 whole branch

Forum: "WinAPI";
Current archive: 2004.12.12;
Download: [xml.tar.bz2];


Memory: 0.56 MB
Time: 0.076 c
Mage Pohmelyaynen
2004-11-24 15:04
About girls and voltmod

2004-09-16 20:36
Console graphics in Delphi

~ Blade ~
2004-11-16 18:41
Update table in ado

2004-12-01 02:19
derivative class your own

Bobby digital
2004-11-28 05:25
Listbox pt.2

afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
English French German Italian Portuguese Russian Spanish