473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Function that's triggered when/before the application closes?

Hello,

I've got some code that I'd like to have execute right before the
application closes, but can't figure out which function to use to do
this.

Much similar to the form_closing function, I'd like to make sure that
the code is executed whenever and however the user exits the
application (specifically... it's UnregisterHotKey()).
Thanks!

Matt
Jun 27 '08 #1
4 1070
Hi Matt,
I've got some code that I'd like to have execute right before the
application closes, but can't figure out which function to use to do
this.
Is this a console application (your 2nd section below may indicate this), or
are you simply implying any application in general?
Much similar to the form_closing function, I'd like to make sure that
the code is executed whenever and however the user exits the
application (specifically... it's UnregisterHotKey()).
--
Martijn
Jun 27 '08 #2
On May 18, 11:12 am, "Martijn"
<subscription_REMOVE_101@hot_REMOVE_mail.comwrot e:
Hi Matt,
I've got some code that I'd like to have execute right before the
application closes, but can't figure out which function to use to do
this.

Is this a console application (your 2nd section below may indicate this), or
are you simply implying any application in general?
Much similar to the form_closing function, I'd like to make sure that
the code is executed whenever and however the user exits the
application (specifically... it's UnregisterHotKey()).

--
Martijn
Thanks for your quick response.

The program is a forms based program, not a console.
Thanks!
Jun 27 '08 #3
Well, assuming you aren't doing anything too funky with threading, how
about just having a "finally" block in your Main() method?

Note that it still can't cope with anything too brutal like a process
kill, and a few fairly terminal exceptions... but:

static void Main(string[] args)
{
try
{
// your app code here
}
finally
{
// your cleanup code here
}
}

Marc
Jun 27 '08 #4
On May 18, 4:31 pm, Marc Gravell <marc.grav...@gmail.comwrote:
Well, assuming you aren't doing anything too funky with threading, how
about just having a "finally" block in your Main() method?

Note that it still can't cope with anything too brutal like a process
kill, and a few fairly terminal exceptions... but:

static void Main(string[] args)
{
try
{
// your app code here
}
finally
{
// your cleanup code here
}
}

Marc
No crazy threading... this will work fine! Thanks!
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ferindo Middleton Jr | last post by:
I am trying to write a Perl Function for one of the databases I'm building a web application for. This function is triggered to occur BEFORE INSERT OR UPDATE. This function is complex in that it...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
6
by: Jim Steinberger | last post by:
Hey all - my inaugural post, I have a Java web application on Tomcat 5 using pg73jdbc3.jar to connect to PostgreSQL 7.3.4 running on the same server (Red Hat Linux ). I have a Perl...
1
by: Donkey Cart Racer | last post by:
Hi, I have a page - page1 which opens a window1 where users can look at tasks, in window1 users can click and open window2 where they can create new tasks I want to refresh window1 when...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: badaczewski | last post by:
The following javascript appears on a popup window. <script language="javascript" type="text/javascript"> function InsertContact(value) { window.opener.CallBackContact(value); window.close();...
1
by: asilter | last post by:
Hi, I'm trying to assign variables where vpSec0 points. void * vpSec0 = NULL; CreateHVFESection0(vpSec0); CreateHVFESection0 function is below.
1
by: =?Utf-8?B?RW5naW5lZXJpaw==?= | last post by:
I have an application which uses a notification icon in the system tray. When the application is closed the notification icon remains in the system tray until I hover over it with the mouse. How...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.