Multithreading – Delphi forms are created without freezing the main thread
I'm in trouble with what I want to do I have some big forms that need some time to create To make the application load faster, I thought I would create the form in the thread created in the oncreate event of the main form Thread has faapplication field of tapplication type, which is obviously an application variable I use it to create forms on threads, but even if I try
FApplication.CreateForm (TfrmXXX,frmXXX)
and
frmXXX := TFrmXXX.Create(FApplication)
The form has not been created yet Is there a solution?
Thank you in advance
Solution
Creating a form in a thread doesn't work at all VCL, especially the visual part, is not thread safe Give up the idea and optimize the code that takes a long time to create the form You didn't tell us what the slow part is If we can answer this question, maybe we can propose an acceleration method
In general, it is impossible to do everything before improving the performance of a piece of code until you analyze it and know exactly where the problem is Otherwise, you just waste your time