djhfwk
(Tom Scott)
1
Steps:
- create a VCLStandalone(RO-based) application.
- put a OpenDialog1 on the fClientForm, drag a button an the form, type:
procedure TClientForm.Button1Click(Sender: TObject);
begin
OpenDialog1.Execute()
end;
- Run the app. click the button, the app hang…
Test platforms:
2003: NOT Hang
Win7: Hang
Win10:Hang
Delphi 10.2
seems the problem is in uROComInit.pas
CoInitializeEx(nil,COINIT_MULTITHREADED);
EvgenyK
(Evgeny Karpov)
2
this is known behavior.
make these changes in .dpr:
- replace
uROComInit
with uROInitializedThread
in uses
- add
ROInitializeThreads := true
like
begin
Application.Initialize;
ROInitializeThreads := true; ///<<<<<<<<<<< added
Application.CreateForm(TFirstSampleService, FirstSampleService);
Application.CreateForm(TFirstSampleServerMainForm, FirstSampleServerMainForm);
Application.Run;
end.
2 Likes
djhfwk
(Tom Scott)
3
uses
uROComInit,
Forms,
fClientForm in ‘fClientForm.pas’ {ClientForm};
I can manually move the unit Forms beyond the unit uROComInit to fixit like this
uses
Forms,
uROComInit,
fClientForm in ‘fClientForm.pas’ {ClientForm};
but i think there is a better way to avoid it
DidierL
(Didier Largange)
4
Seems like the order is important:
Application.Initialize; // 1
ROInitializeThreads := true; // 2