Groups | Blog | Home
all groups > dotnet remoting > july 2006 >

dotnet remoting : Remoting and Windows Forms - Deadlock?


CDX
7/1/2006 12:00:00 AM
I have what appears to be a deadlock issue in a simple remoting application
consisting of 3 objects:

1) A server side Singleton
2) A client-side windows form
2) A client side helper to facilitate communication between the two

SITUATION ONE
I successfully implemented remote callback on the client side. A timer on
the server-side object fires a remote method on the client-side helper. This
in turn fires an event which is picked up by the form. Using Invoke(), I
ensure that the value of the timer, read from the event, updates the form in
a thread-safe way. I used RemotingServices.IsTransparentProxy() to check
everything was running where I thought it was. All fine so far.

SITUATION TWO
I then tried to pass the value from the Windows form to the server, on a
button click, so that instead of a server-side timer generating it, the
value received by the form would be the one generated by the form itself.
The form passes the value to the client-side helper, which passes it to the
server, which makes a remote callback to the client helper again. Everything
works fine as far as this. But instead of the form obediently catching the
event fired by the helper and updating its interface, the IDE freeze, the
form refuses to repaint, and the application hangs.

SITUATION THREE
If I implement a timer in the client-side helper so that my button click to
update the value fires the timer, which then passes the value to the server,
everything is fine. The helper gets its method call from the server, fires
its event which is picked up by the form, and the UI value is updated. I can
use this as a work-around, but it's not exactly elegant code.

This is mystifying. I am obviously missing something big here. Situation 3
tells me that for some reason my UI thread for the form is not returning
like I think it is, which seems obvious where remoting is involved. But the
problem seems to lie between the two client-side objects ......


CDX
7/1/2006 12:00:00 AM
Fixed this. My own fault - I was trying to dispatch the server call on a
separate thread using MethodInvoker(). As soon as I just called it
directly - fine.

[quoted text, click to view]

Spam Catcher
7/2/2006 7:16:17 PM
"CDX" <CDX@community.nospam> wrote in news:OrcwGgOnGHA.3656
@TK2MSFTNGP03.phx.gbl:

[quoted text, click to view]

Windows forms are single threaded... so you'll need to use BeginInvoke to
AddThis Social Bookmark Button