First change your onMessage
method to static
because Main
method is static.You can't access a non-static method from inside static
context:
public static void onMessage(Message m)
Then attach your event handler like this:
first.send += new Test.AEventHandler(onMessage);
Or short version:
first.send += onMessage;