Partager via


OneWay messages in remoting

Remoting provides a way for fire-and-forget OneWay messages from client to the server. Just adding a [OneWay] attribute to a method of your remoted type would make the method invokation oneway. Something like:

public class Remote : MarshalByRefObject
{
public void RemoteMethod ()
{}

  [OneWay]
public void RemoteOneWayMethod()
{}
}

When invoking a oneway method the client will not wait for a response and the call will return immediately. In essence the call gets converted to an async call and the client doesnt wait for a server response.

Note: This behaviour occurs only when invoking a method marked with [OneWay] on a remoting proxy. Invoking the same method on a regular object will not have the desired effect. It will be called synchronously like any other method.

Comments

  • Anonymous
    October 20, 2004
    That is does; however since you are not assured of knowing that the data went through, I've always found this feature to be somewhat less than useful.
  • Anonymous
    October 20, 2004

    Yes you are correct, it could be useful in a x-appdomain scenario however where you are sure the channel is reliable.

    Thanks
  • Anonymous
    October 20, 2004
    Ah, that's a very good point. :)
  • Anonymous
    October 25, 2004
    "In essence the call gets converted to an async call and the client doesnt wait for a server response."

    Does that mean that calls to a method marked OneWay would ALWAYS be aynch?

    I need to clean up some temp files on session start.I have the method marked OneWay that does that - but I do not want to wait on files deletion - so I have a delegate hook up that method and I do a MyDelegateInstance.BeginInvoke on the method.

    Is that redundant since the call is already asynch?


    informative blog by the way - thanx
  • Anonymous
    October 26, 2004
    Anil,

    This is a good question. I should have clarified this in the post. The async behaviour for [OneWay] messages is true, only when you are invoking a method on a proxy. If you are invoking on a regular object you will not get this behaviour. Hope this clarifies your doubt.

    Thanks.
  • Anonymous
    January 20, 2009
    PingBack from http://www.hilpers.com/306515-remoting-callback-server-client