Getting event subsription to work in VB?

Oct 8, 2008 at 3:04 PM
Hi all, I'm having an issue getting event subsription to work in VB, more so the action parameter and it's handler.

C#
fundAddedEvent.Subscribe(FundAddedEventHandler, ThreadOption.UIThread, true);


        void FundAddedEventHandler(FundOrder fundOrder)
        {
            Debug.Assert(View != null);
            View.AddContent(fundOrder.TickerSymbol);
        }

VB
What should this look like in VB including FundAddedEventHandler?

Many thanks.
Oct 8, 2008 at 5:36 PM

Hi,

 

The matching code in VB would be:

 

fundAddedEvent.Subscribe(AddressOf FundAddedEventHandler, ThreadOption.UIThread, True)

 

Sub FundAddedEventHandler(ByVal fundOrder As FundOrder)

    Debug.Assert(View IsNot Nothing)

    View.AddContent(fundOrder.TickerSymbol)

End Sub

 

You may also express a condition for the subscription with a lambda expression as follows:

 

fundAddedEvent.Subscribe(AddressOf FundAddedEventHandler, ThreadOption.UIThread, True, Function(fundOrder) fundOrder.CustomerId = "Customer1")

 

Please, let me know if this helps.

 

Ignacio Baumann Fonay

http://blogs.southworks.net/ibaumann/