BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help - Marshalling... i'm really stuck!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Usage
View previous topic :: View next topic  
Author Message
William Buchanan
Guest





PostPosted: Tue Jul 22, 2003 9:47 am    Post subject: Help - Marshalling... i'm really stuck! Reply with quote



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;



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Usage All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.