KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a problem. I have a VCL application using a thread. This thread does some calculations and calls a MainForm's method through Synchronize(). It all works just fine, I have a "Start" button, which creates and runs the thread and a "Stop" button which stops and frees it. No errors, no nothing. But for some reason when I close the application and I've run the thread I get a EOSError 1400 - Invalid window handle . I've breakpointed the OnClose procedure and the only thing I do there is saving an ini file, no error in that, when I trace further (using F7), I get to the very end ( Application.Run; end. ), after "calling" the end. I get the error, so there is no specific line of code raising it. I hope the question is somewhat clear and I hope it's solvable, because just ignoring the error seems a bit unclean. Thanks inb4 ANSWER This error occured to me when the Execute method of a thread was called, it looked like this: procedure TRunThread.Execute; var (...) begin while not Terminated do begin (...) MainForm.Memo1.Lines.Add('Some text'); // Even though this call worked fine during //the application running, it caused errors on shutting the app down. // For acccessing GUI elements, it's necessary to use Synchronize() (...) end; end;
Tags (comma-separated)
Save Edits
Cancel