views:

11

answers:

0

Hey all... I was building a quick mock-up of a WeakEventManager/Listener using buttons but after two clicks, the StopListening event is getting fired and I'm not quite sure why.

Essentially, the Manager is listening for Click events. My listener gets instantiated in the Window1_Initialized event

Application.Current.Properties.Add("EventManager", New EventManager) Dim obj As MyListener = New MyListener(cmdOne, True, "Button 1")

The New call looks like:

Me.button = cmdbutton
Me.id = sid
If UsingEvent Then
Ctype(Application.Current.Properties("EventManager"), EventManager).AddListener(cmdbutton, Me)

End If

And the ReceiveWeakEvent looks like:

If managerType Is GetType(EventManager) Then
        ImClicked(sender, e) ' this just displays a messagebox
                Return True
Else
                Return False
End If

When I run it and click the button, the imClicked method fires.

But when I click the button twice, on the third time, it immediately fires the StopListening method.

Am I missing something obvious? Or is this a case where the Messagebox is what is getting in the way?

Thanks