I am trying to use a COM interface in a stream. From what I read, I should call CoInitialize/CoUninitialize in each thread.
While this works fine:
procedure TThreadedJob.Execute; begin CoInitialize(nil); // some COM stuff CoUninitialize; end;
when I go to constructor and destructor:
TThreadedJob = class(TThread) ... protected procedure Execute; override; public constructor Create; destructor Destroy; override; ... constructor TThreadedJob.Create; begin inherited Create(True); CoInitialize(nil); end; destructor TThreadedJob.Destroy; begin CoUninitialize; inherited; end; procedure TThreadedJob.Execute; begin // some COM stuff end;
I get an EOleException: CoInitialize was not caused by an exception, and I don't know why.
multithreading delphi com ole
forsight
source share