Re: Direct Remoting event issue?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: A. Burch (a1_dog_at_msn.com)
Date: 04/15/04


Date: Wed, 14 Apr 2004 23:19:30 -0700

Thanks for the code but.....

The Event Wrapper Class compiled fine into a dll, but using it in the client
gave a problem...
The client code gives an error when compiling the client code at this
line....

EventWrapper wrapper = new EventWrapper(this.ClientEventHandler);

The error is this about referenced without parentheses, I've tried alot of
things but can't find why the error occurs. Why this error????.

 Method 'Admins.frmAdmin.ClientEventHandler(int)' referenced without
parentheses

Code......

public delegate void EventHandler(int eventVal);

public class EventWrapper : MarshalByRefObject
{
/// <summary>
/// Event fired localy at the client. Client handler have to be hooked
/// here.
/// </summary>
public event EventHandler MyEvent;

/// <summary>
/// Default ctor.
/// </summary>
public EventWrapper() : this(null){}

/// <summary>
/// Creates new instance and hooks the handler if != null
/// </summary>
public EventWrapper(EventHandler handler)
{
if (handler != null)
this.MyEvent += handler;
}

/// <summary>
/// This have to be provided as a handler to server event.
/// </summary>
/// <param name="pagecount">Total pages.</param>
/// <param name="pagesdone">Pages processed so far.</param>

public void MyEventHandler(int eventVal)
{
if (this.MyEvent != null)
this.MyEvent(eventVal);
}

}

client code:
--------------

EventWrapper wrapper = new EventWrapper(this.ClientEventHandler);
serverObj.ServerEvent += wrapper.MyEventHandler;

....
public void ClientEventHandler(int eventVal)
{
Console.WriteLine("Value received: " + eventVal.ToString());
}



Relevant Pages

  • Re: Use of AssertionError
    ... // Use this handler as the class ... Is it more appropriate to put a RuntimeException or other type of error instead of using an AssertionError here? ... The program is in an illegal state, therefore IllegalStateException. ... Client code will not be able to recover from an AssertionError. ...
    (comp.lang.java.programmer)
  • Re: Use of AssertionError
    ... // Use this handler as the class ... Is it more appropriate to put a RuntimeException or other type of error instead of using an AssertionError here? ... The program is in an illegal state, therefore IllegalStateException. ... Client code will not be able to recover from an AssertionError. ...
    (comp.lang.java.programmer)