Handler

Hi

I'm looking at some legacy code in VB.net and wondering what the code does. Here is a snippet:

    Public Sub RegisterHandler(ByVal handler As CloseApplication)

        Me.m_handler = handler

    End Sub

    Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)

        If Not m_handler Is Nothing And Me.m_confirmClicked = False Then
            m_handler.Invoke()
        End If

    End Sub

Can anybody explain what the m_handler variable is doing?

Issac
IssacJonesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ItpotterCommented:
Its a delegate that might is getting used for some cleanup work when application is closing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jacques Bourgeois (James Burger)PresidentCommented:
The handler is an object that reference a method, a Delegate object as Itpotter said.

Invoke calls that method. This is an indirect way to call a method.

It is usually used call a method when you do not know its name at the time you write the code. For instance, events are handled that way by the system. When you open a form, the system send a handler to all your events to the dll that contains the code for the controls. The controls can thus call your event procedures even if it does not know their name.
0
IssacJonesAuthor Commented:
Thanks guys
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.