William Buchanan Guest
|
Posted: Tue Jul 22, 2003 9:47 am Post subject: Help - Marshalling... i'm really stuck! |
|
|
Hi folks
I have a client which has a TClientDataSet which connects to an app server
through a TDCOMConnection.
I open the CDS in a thread - this works fine.
However, when I want to close and open the CDS I keep getting an error that
the application called an interface that was marshalled for a different
thread.
Can anybody help me with this?? I have pasted code below...
Thanks
Will
Client
=====
private
FStream: Pointer;
......
FStream := nil;
CoMarshalInterThreadInterfaceInStream(IID_IAppServer,
Fdm.cdsMatchSite.AppServer, IStream(FStream));
GSiteMatchThr := TThrSiteMatch.Create( self, FStream,
Fdm.cdsMatchSite,
aCont.FCompName, aCont.FCountry );
Thread
======
private
FCds: TClientDataSet;
FApp: IAppServer;
constructor
FStream := stream; // stream passed in from main thread
.....
execute
res := CoInitialize( nil );
if not( res = S_OK ) then
raise Exception.Create( 'CoInitialize failed in TThrSiteMatch.Execute.
' +
SysErrorMessage( Res ) );
try
OleCheck( CoGetInterfaceAndReleaseStream( IStream( FStream ),
IID_IAppServer, FApp ) );
with FCDS do
begin
AppServer := FApp;
Close;
Params.ParamByName('COMPANYNAME').AsString := UpperCase( Copy(
FCompName, 1, 3 ) );
Params.ParamByName('COUNTRY').AsString := FCountry;
Open;
end;
Synchronize( NotifyClient );
CoUnInitialize;
FStream := nil;
|
|