Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Raise event from SAO

Back to Forum: Tech Off
  • User profile image

    Ok, lets say I have a class:

    Public Class Foo
       Inherits MarshalByRefObject
       Public Event CalculationStarted()
       Public Sub New()
          RaiseEvent CalculationStarted()
       End Sub

    Then I have a console app that registers this object:

    Sub Main()
       Dim chnl As New  System.Runtime.Remoting.Channels.Tcp.TcpChannel(1234)
    GetType(Foo), "FOOService", Runtime.Remoting.WellKnownObjectMode.Singleton)
    End Sub

    I would like to have an even handeler in the console app to handle various events as they happen in the object, but I can't for the life of me figure out how to get a handle to hook to the objects event.

    Any Ideas?


  • User profile image

    You can create an object and then register it for remoting using the RemotingServices.Marshal method.

    Something like

    Foo f = new Foo();
    f.SomeEvent += ...;
    System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(Foo), "FOOService", Runtime.Remoting.WellKnownObjectMode.Singleton);

  • User profile image

    Thanks! I'll give it a try.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.