Hi all,
my main form has several buttons that each open another form in a modal manner. The other forms return their results via ModalResult := xyz, which also closes them. The main form then uses the result of ShowModal do determine what to do next. That all works nicely.
But I have one form that uses a background thread to carry out a lengthy operation. The background thread uses Synchronize on a method of the form to report progress back, so I can update UI elements. That's fine, too. But when the lengthy operation is finished it should also set ModalResult. This basically works, too, but does not take effect immediately. Instead, I need to move the mouse (or generate another event or wait several seconds) for the form to close and the application to proceed. I tried reporting my results to the CurrentThread of the form instead of the main thread, assuming it may be a different one due to the modal magic, but this did not seem to solve it.
What is the proper way to deal with a situation like this?
I'm on an Intel MacOS running Monterey, FPC 3.2.2 and Lazarus 2.2.6.
Cheers!
Joerg