Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium



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

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
        End If

    End Sub

Can anybody explain what the m_handler variable is doing?

Question by:IssacJones

Accepted Solution

Itpotter earned 500 total points
ID: 37043672
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)
Jacques Bourgeois (James Burger) earned 500 total points
ID: 37044196
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

ID: 37061720
Thanks guys

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

578 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