Board index » delphi » Multiple threads and Remote Data Module

Multiple threads and Remote Data Module

    I don't know if this is the correct thread for this question, but
couldn't find one on midas. I have an application that consists of a client
and remote server. The remote server is made up of remote data modules that
use the apartment threading model. For almost all functionality this
structure works well, except when I come up against an application function
that takes a long time. Here I'd like to spawn a thread to actually do the
work and return control to the client to do other work. My problem is this:
when I spawn the thread on the server, I end up with an immediate address
exception whenever the thread tries to access the remote data modules
queries/datasets. This must be a very common requirement from an application
server, but I can't seem to get it to work properly.

    I also tried the approach of spawning a separate thread on the client.
This gets me an application coinitialize error. I called coinitialize in the
other thread, but then ran into marshalling errors, I am not sure which
objects to marshal in the ole connection object.

    I would greatly appreciate it if anyone could point me to information
regarding this issue.

    Thanks,

    John Campbell

 

Re:Multiple threads and Remote Data Module


Quote
"John Campbell" <jycampb...@snet.net> wrote in message

news:3b4a6f1a$1_1@dnews...

Quote
>     I don't know if this is the correct thread for this question, but
> couldn't find one on midas. I have an application that consists of a
client
> and remote server. The remote server is made up of remote data modules
that
> use the apartment threading model. For almost all functionality this
> structure works well, except when I come up against an application
function
> that takes a long time. Here I'd like to spawn a thread to actually do the
> work and return control to the client to do other work. My problem is
this:
> when I spawn the thread on the server, I end up with an immediate address
> exception whenever the thread tries to access the remote data modules
> queries/datasets. This must be a very common requirement from an
application
> server, but I can't seem to get it to work properly.

I don't believe the BDE components are threadsafe. That probably explains
your exceptions.

Quote
>     I also tried the approach of spawning a separate thread on the client.
> This gets me an application coinitialize error. I called coinitialize in
the
> other thread, but then ran into marshalling errors, I am not sure which
> objects to marshal in the ole connection object.

There was an example of a threaded CDS posted by Dan Miser a while back. The
mechanics of CoInitialize and marshalling can be studied from the source
code to that sample. Perhaps it's still on distribucon.com.

--
have fun
Binh Ly
http://www.techvanguards.com

Other Threads