Posted on 2011-10-28
Last Modified: 2012-05-12

I'm looking at some legacy code in 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
        End If

    End Sub

Can anybody explain what the m_handler variable is doing?

Question by:IssacJones
    LVL 1

    Accepted Solution

    Its a delegate that might is getting used for some cleanup work when application is closing.
    LVL 40

    Assisted Solution

    by:Jacques Bourgeois (James Burger)
    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.

    Author Closing Comment

    Thanks guys

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now