Board index » delphi » Threads and COM - Basic question

Threads and COM - Basic question

Using D5 pro,

I have an out of Proc COM server(COM) that I want to update from
another application(App1).
This works fine with:

procedure Tform1.refreshList;
var
   iPplCli:IpplLst;
begin
  try
     iPplCli := coPplLst.Create as IpplLst;
     iPplCli.ListRefresh;
  except
  end;
end;

However, this takes some time and I don't want my app to have to wait
until refresh returns.
My thought was to create a thread in the App1 with an execute that
does the above.

procedure TPpliCliRefreshThread.Execute;
var
   iPplCli:IpplLst;
begin
  try
     iPplCli := coPplLst.Create as IpplLst;
     iPplCli.ListRefresh;
  except
  end;
end;

However I get an EoleSysError telling me coinitialize was not called.
What do I need to do?
Should the thread really be in the COM server with waitfor set to
false rather than in the App1?  Or do I need to change some flags in
the COM factory or What?

Any help is greatly appreciated, I am obviously not grasping something
basic.

Ralph

 

Re:Threads and COM - Basic question


Apply this pattern:

proc TMyThread.Execute;
begin
  CoInitialize (nil);
  AllocInterfacePointers;
  UseInterfacePointers;
  ReleaseInterfacePointers;
  CoUninitialize;
end;

--
have fun
Binh Ly
www.techvanguards.com

Quote
"RHTuttle" <ralph.tut...@visi.com> wrote in message

news:3b097900$1_2@dnews...
Quote
> Using D5 pro,

> However I get an EoleSysError telling me coinitialize was not called.
> What do I need to do?
> Should the thread really be in the COM server with waitfor set to
> false rather than in the App1?  Or do I need to change some flags in
> the COM factory or What?

Re:Threads and COM - Basic question


Thanks Binh, that did the trick.

Ralph

Quote
"Binh Ly" <b...@castle.net> wrote in message news:3b09caf8$2_1@dnews...
> Apply this pattern:

> proc TMyThread.Execute;
> begin
>   CoInitialize (nil);
>   AllocInterfacePointers;
>   UseInterfacePointers;
>   ReleaseInterfacePointers;
>   CoUninitialize;
> end;

> --
> have fun
> Binh Ly
> www.techvanguards.com

> "RHTuttle" <ralph.tut...@visi.com> wrote in message
> news:3b097900$1_2@dnews...
> > Using D5 pro,

> > However I get an EoleSysError telling me coinitialize was not
called.
> > What do I need to do?
> > Should the thread really be in the COM server with waitfor set to
> > false rather than in the App1?  Or do I need to change some flags
in
> > the COM factory or What?

Other Threads