[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

koic

10/26/2004 10:58:00 PM

I have a client and a server.
The client creates an instance of ObjA which contains an instance of ObjB and ObjC and registers event of ObjB with handler in ObjC.

Then the entire ObjA is sent to the server via a remote call to AcceptObject. The passed ObjA is stored in a private variable of the server. Then the client calls another method on the server: RunObject() which invokes Run() on ObjA, this in turn raises the event Evt on ObjB and is handled by ObjC. The event is raised, but is redirected to the client where the object was created.

My question is:
How can I make the event be raised on the remote server instead of the client?

Thanks in advance

The simplified code follows:

Public Class ServerClass
Private _a as ObjA
Public Sub AcceptObject(byval a as ObjA)
_a = a
End Sub

Public Sub RunObject()
_a.Run()
End Sub
End Class

Public Class ObjA
Private _b as ObjB
Private _c as ObjC
Public Sub New()
_b = New ObjB
_c = New ObjC
AddHandler _b.Evt, AddressOf _c.HandleEvt
End Sub

Public Sub Run()
_b.RaiseEvent
End Sub
End Class

Public Class ObjB
Public Event Evt()
Public Sub Raise()
RaiseEvent Evt()
End Sub
End Class

Public Class ObjC
Public Sub HandleEvt()
Console.write("Event Handled")
End Sub
End Class



---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/... Our newsgroup engine supports Post Alerts, Ratings, and Searching.
1 Answer

Ken Kolda

10/27/2004 3:20:00 PM

0

One or more of your classes must derive from MarshalByRefObject, which means
the class lives on the client. So, when the event is raised, the event
occurs on the client. When using remoting you need to be very careful to
make sure you know exactly what objects will live on the client and the
server. Your architecture isn't going to help with that -- you may want to
simplify/modify your class hierarchy/relations.

Ken


"koic" <koic@-NOSPAM-DotNetJunkies.com> wrote in message
news:eyNSt86uEHA.1988@TK2MSFTNGP12.phx.gbl...
> I have a client and a server.
> The client creates an instance of ObjA which contains an instance of ObjB
and ObjC and registers event of ObjB with handler in ObjC.
>
> Then the entire ObjA is sent to the server via a remote call to
AcceptObject. The passed ObjA is stored in a private variable of the server.
Then the client calls another method on the server: RunObject() which
invokes Run() on ObjA, this in turn raises the event Evt on ObjB and is
handled by ObjC. The event is raised, but is redirected to the client where
the object was created.
>
> My question is:
> How can I make the event be raised on the remote server instead of the
client?
>
> Thanks in advance
>
> The simplified code follows:
>
> Public Class ServerClass
> Private _a as ObjA
> Public Sub AcceptObject(byval a as ObjA)
> _a = a
> End Sub
>
> Public Sub RunObject()
> _a.Run()
> End Sub
> End Class
>
> Public Class ObjA
> Private _b as ObjB
> Private _c as ObjC
> Public Sub New()
> _b = New ObjB
> _c = New ObjC
> AddHandler _b.Evt, AddressOf _c.HandleEvt
> End Sub
>
> Public Sub Run()
> _b.RaiseEvent
> End Sub
> End Class
>
> Public Class ObjB
> Public Event Evt()
> Public Sub Raise()
> RaiseEvent Evt()
> End Sub
> End Class
>
> Public Class ObjC
> Public Sub HandleEvt()
> Console.write("Event Handled")
> End Sub
> End Class
>
>
>
> ---
> Posted using Wimdows.net NntpNews Component -
>
> Post Made from http://www.DotNetJunkies.com/... Our newsgroup
engine supports Post Alerts, Ratings, and Searching.