 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Fred Guest
|
Posted: Wed Jan 24, 2007 3:24 pm Post subject: Fetch data in a background thread? |
|
|
I have a case where I would like to have more then one SocketConnection
"talking" to the AppServer so I can run a data fetching in the background.
My idea is that the SocketConnections are created in the context of the main
thread and each time I need to fetch data in the background I create a new
search thread which is then getting one socketconnection in order to fetch
data.
Since the AppServer interface is created in the context of the main thread I
need to marshal the interface into the search thread. I have past experience
in marshalling interface between threads. The problem I encounter is that
when I am trying to unmarshal the IAppServer interface.
constructor TSearchThread.Create(CDS: TClientDataSet; OwnerHandle :
THandle);
begin
FreeOnTerminate := true;
FOwnerHandle := OwnerHandle;
FCDS := CDS;
FCount := FCDS.PacketRecords;
//Marshall the AppServer interface into the stream...
OleCheck(CoMarshalInterThreadInterfaceInStream(IAppServer, CDA.AppServer
as IUnknown, IStream(FStream)));
inherited Create(false);
end;
procedure TSearchThread.Execute;
var
Options: TGetRecordOptions;
AppSrv: IAppServer;
....
begin
OleCheck(CoInitialize(nil));
try
//Unmarshal the interface
OleCheck(CoGetInterfaceAndReleaseStream(IStream(FStream), IAppServer,
AppSrv)); <------ error!
This last row is not working I am getting the error "An error occured when a
typ library or a DLL-file could not be read". This error message is
translated from Swedish so it may not be the correct in English. AppSrv:
IAppServer; is declared in the TSearchThread class.
Can anyone help me out here? Please any idea is appreciated!
TIA
Fred |
|
| Back to top |
|
 |
A Pham Guest
|
Posted: Thu Jan 25, 2007 9:59 pm Post subject: Re: Fetch data in a background thread? |
|
|
Just a guess
Move the call "CoMarshalInterThreadInterfaceInStream" after "CoInitialize"
Cheers
A Pham
"Fred" <fredrik.ahlen (AT) teliasonera (DOT) com> wrote in message
news:45b725c5$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I have a case where I would like to have more then one SocketConnection
"talking" to the AppServer so I can run a data fetching in the background.
My idea is that the SocketConnections are created in the context of the
main
thread and each time I need to fetch data in the background I create a new
search thread which is then getting one socketconnection in order to fetch
data.
Since the AppServer interface is created in the context of the main thread
I
need to marshal the interface into the search thread. I have past
experience
in marshalling interface between threads. The problem I encounter is that
when I am trying to unmarshal the IAppServer interface.
constructor TSearchThread.Create(CDS: TClientDataSet; OwnerHandle :
THandle);
begin
FreeOnTerminate := true;
FOwnerHandle := OwnerHandle;
FCDS := CDS;
FCount := FCDS.PacketRecords;
//Marshall the AppServer interface into the stream...
OleCheck(CoMarshalInterThreadInterfaceInStream(IAppServer, CDA.AppServer
as IUnknown, IStream(FStream)));
inherited Create(false);
end;
procedure TSearchThread.Execute;
var
Options: TGetRecordOptions;
AppSrv: IAppServer;
...
begin
OleCheck(CoInitialize(nil));
try
//Unmarshal the interface
OleCheck(CoGetInterfaceAndReleaseStream(IStream(FStream), IAppServer,
AppSrv)); <------ error!
This last row is not working I am getting the error "An error occured when
a
typ library or a DLL-file could not be read". This error message is
translated from Swedish so it may not be the correct in English. AppSrv:
IAppServer; is declared in the TSearchThread class.
Can anyone help me out here? Please any idea is appreciated!
TIA
Fred
|
|
|
| Back to top |
|
 |
|
|
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
|
|