How do I handle this syncornization with remoting?

G

Grant Schenck

Hello,

I'm just starting with .NET remoting. Here is what I'm not sure how to
handle.

I have a IPC Channel remoting server. It exports an object and I can call a
method on that object just fine. I'd like to kick off some activity and
block until the activity completes.

The completion arrives as a COM call back on a thread from the COM object so
really my question is:

What is a straight forward .NET way to have the .NET remote call block on
something and then be released?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Grant,

There are a few things here that don't make sense. See inline:
I'm just starting with .NET remoting. Here is what I'm not sure how to
handle.

I have a IPC Channel remoting server. It exports an object and I can call
a method on that object just fine. I'd like to kick off some activity and
block until the activity completes.

If you just make a regular call across a remoting channel, the call
blocks until the method is complete. Your code doesn't continue to execute
while the proxy on the client side is waiting for the call on the server to
complete.
The completion arrives as a COM call back on a thread from the COM object
so really my question is:

That doesn't make sense. What is a "COM call back" (I'm thinking
connection points here, but that makes no sense in this context). Are you
exporting an unmanaged COM object as a remoting endpoint? If so, that's
probably a bad, bad idea.

How is COM involved in this?
 
G

Grant Schenck

Hi Nicholas,

Thanks for responding. See below...
--
Grant Schenck

Nicholas Paldino said:
Grant,

There are a few things here that don't make sense. See inline:


If you just make a regular call across a remoting channel, the call
blocks until the method is complete. Your code doesn't continue to
execute while the proxy on the client side is waiting for the call on the
server to complete.

[GRANT] Correct, the client blocks until I eventually complete.
That doesn't make sense. What is a "COM call back" (I'm thinking
connection points here, but that makes no sense in this context). Are you
exporting an unmanaged COM object as a remoting endpoint? If so, that's
probably a bad, bad idea.

How is COM involved in this?

[GRANT] I use an unmanged COM object which provides call backs to the
service. This part works fine. The connection to remoting is that the
request which comes in via remoting to the server does some setup and then
needs to block until an asyncronous event arrives at the COM object.

What I want to do in the remoted method in the server is:
- Setup some stuff.
- Create some kind of signalling object
- Block waiting for the object to signal.

The other thread (the fact that it is COM is really not relevent) at some
point completes the work intiiated by the setup and then needs to signal the
blocked method to release it and allow it to complete and therefore the
client to returned to. It may take up to a minute before the request
completes.

Basicly I'm building a command line utility which talks to a server via an
IPC channel. This server uses the services of a COM object to place a call
but I don't want to complete the method until the call connects or I want to
give up watiing for the call to connect. Therefore, I need a way to release
the waiting method from a separate thread which handles events generated by
the COM object.
 
N

Nicholas Paldino [.NET/C# MVP]

Grant,

In this case, what you want to do is create a WaitHandle (a
ManualResetEvent works fine). In the method that makes the call to your COM
object, you make a call to WaitOne after you make the async call to the COM
object.

Then, in the callback for the async operation on the COM object, you
call Set on the ManualResetEvent and it will release the thread and then
return from the server (of course, you have to set any return values in a
location that the waiting method can access).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Grant Schenck said:
Hi Nicholas,

Thanks for responding. See below...
--
Grant Schenck

Nicholas Paldino said:
Grant,

There are a few things here that don't make sense. See inline:


If you just make a regular call across a remoting channel, the call
blocks until the method is complete. Your code doesn't continue to
execute while the proxy on the client side is waiting for the call on the
server to complete.

[GRANT] Correct, the client blocks until I eventually complete.
That doesn't make sense. What is a "COM call back" (I'm thinking
connection points here, but that makes no sense in this context). Are
you exporting an unmanaged COM object as a remoting endpoint? If so,
that's probably a bad, bad idea.

How is COM involved in this?

[GRANT] I use an unmanged COM object which provides call backs to the
service. This part works fine. The connection to remoting is that the
request which comes in via remoting to the server does some setup and then
needs to block until an asyncronous event arrives at the COM object.

What I want to do in the remoted method in the server is:
- Setup some stuff.
- Create some kind of signalling object
- Block waiting for the object to signal.

The other thread (the fact that it is COM is really not relevent) at some
point completes the work intiiated by the setup and then needs to signal
the blocked method to release it and allow it to complete and therefore
the client to returned to. It may take up to a minute before the request
completes.

Basicly I'm building a command line utility which talks to a server via an
IPC channel. This server uses the services of a COM object to place a
call but I don't want to complete the method until the call connects or I
want to give up watiing for the call to connect. Therefore, I need a way
to release the waiting method from a separate thread which handles events
generated by the COM object.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
What is a straight forward .NET way to have the .NET remote call block
on something and then be released?

Thanks!
 
G

Grant Schenck

Thanks!

I think you nailed what I'm trying to do to a "T"!

I'll code it up tomorrow!

Grant

Nicholas Paldino said:
Grant,

In this case, what you want to do is create a WaitHandle (a
ManualResetEvent works fine). In the method that makes the call to your
COM object, you make a call to WaitOne after you make the async call to
the COM object.

Then, in the callback for the async operation on the COM object, you
call Set on the ManualResetEvent and it will release the thread and then
return from the server (of course, you have to set any return values in a
location that the waiting method can access).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Grant Schenck said:
Hi Nicholas,

Thanks for responding. See below...
--
Grant Schenck

Nicholas Paldino said:
Grant,

There are a few things here that don't make sense. See inline:

I'm just starting with .NET remoting. Here is what I'm not sure how to
handle.

I have a IPC Channel remoting server. It exports an object and I can
call a method on that object just fine. I'd like to kick off some
activity and block until the activity completes.

If you just make a regular call across a remoting channel, the call
blocks until the method is complete. Your code doesn't continue to
execute while the proxy on the client side is waiting for the call on
the server to complete.

[GRANT] Correct, the client blocks until I eventually complete.
The completion arrives as a COM call back on a thread from the COM
object so really my question is:

That doesn't make sense. What is a "COM call back" (I'm thinking
connection points here, but that makes no sense in this context). Are
you exporting an unmanaged COM object as a remoting endpoint? If so,
that's probably a bad, bad idea.

How is COM involved in this?

[GRANT] I use an unmanged COM object which provides call backs to the
service. This part works fine. The connection to remoting is that the
request which comes in via remoting to the server does some setup and
then needs to block until an asyncronous event arrives at the COM object.

What I want to do in the remoted method in the server is:
- Setup some stuff.
- Create some kind of signalling object
- Block waiting for the object to signal.

The other thread (the fact that it is COM is really not relevent) at some
point completes the work intiiated by the setup and then needs to signal
the blocked method to release it and allow it to complete and therefore
the client to returned to. It may take up to a minute before the request
completes.

Basicly I'm building a command line utility which talks to a server via
an IPC channel. This server uses the services of a COM object to place a
call but I don't want to complete the method until the call connects or I
want to give up watiing for the call to connect. Therefore, I need a way
to release the waiting method from a separate thread which handles events
generated by the COM object.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


What is a straight forward .NET way to have the .NET remote call block
on something and then be released?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top