473,378 Members | 1,377 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,378 software developers and data experts.

How to run clean-up-code when Application shuts down.

I want to run some code when my Windows Form Application is being shut
down.

I want to run this code when the Application is being shut down in the
following situation:

1. The App is being shut down by the user.
2. The App is being shut down because of Windows System Shut Down.

3. The App Process is being killed in Task Manager
4. The App is shut down because I click "Stop" in Visual Studio.
5. The App is shut down, because of some reason I forget in this list.

3,4 and 5, ofcause only if possible.

How do I Achive this, in what event should I put my code ??

Best Regards , Anders Both - Denmark.

Nov 17 '05 #1
4 1854
My advice u to implement IDisposable interface. On dispose method cleanup
any resource that u like to give back...

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

<an********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I want to run some code when my Windows Form Application is being shut
down.

I want to run this code when the Application is being shut down in the
following situation:

1. The App is being shut down by the user.
2. The App is being shut down because of Windows System Shut Down.

3. The App Process is being killed in Task Manager
4. The App is shut down because I click "Stop" in Visual Studio.
5. The App is shut down, because of some reason I forget in this list.

3,4 and 5, ofcause only if possible.

How do I Achive this, in what event should I put my code ??

Best Regards , Anders Both - Denmark.

Nov 17 '05 #2
Hi,

Use Application.ApplicationExit event

I'm not sure if it does work in 3 though. but you can try it anyway.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
<an********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I want to run some code when my Windows Form Application is being shut
down.

I want to run this code when the Application is being shut down in the
following situation:

1. The App is being shut down by the user.
2. The App is being shut down because of Windows System Shut Down.

3. The App Process is being killed in Task Manager
4. The App is shut down because I click "Stop" in Visual Studio.
5. The App is shut down, because of some reason I forget in this list.

3,4 and 5, ofcause only if possible.

How do I Achive this, in what event should I put my code ??

Best Regards , Anders Both - Denmark.

Nov 17 '05 #3
Of course the fundemental problem is someone has to *call* your Dispose method because the runtime certainly won't. Where are you going to put the call to Dispose?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

My advice u to implement IDisposable interface. On dispose method cleanup
any resource that u like to give back...
Nov 17 '05 #4
For the class that must be disposed. I implement IDisposable interface and
create an instance of that class with using keyword. It always calls dispose
method after leaving the scope..

Am I right?

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> wrote in
message news:O7**************@TK2MSFTNGP15.phx.gbl...
Of course the fundemental problem is someone has to *call* your Dispose
method because the runtime certainly won't. Where are you going to put the
call to Dispose?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

My advice u to implement IDisposable interface. On dispose method
cleanup
any resource that u like to give back...

Nov 17 '05 #5

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

Similar topics

2
by: Jason | last post by:
I have a number of arrays that are populated with database values. I need to determine which array has the highest ubound out of all the arrays. The array size will always change based on the...
7
by: Creative Acceleration | last post by:
Hi all, I need to convert the Query Strings into Clean URLs, Found some articles on PHP and Apache server.. How do we it them with ASP ?? Thanks Kart
0
by: John . | last post by:
I have a Windows XP/SP2 home system that due to some memory modules errors has partially corrupted the .NET 1.1 environment. I re-registered some modules using KB82463 and KB281679 using...
0
by: Ed J | last post by:
How do I "clean" intermediate/executable files out of a VB.Net project? I added both the "Clean Solution" and "Clean Selection" commands to the Visual .NET 2003 menus, but both options stay...
3
by: pedro8ae | last post by:
If I build a form to input data into a table every time I open the form I am seeing the data I enter the last time my question is how every time I save data in my form I get a clean set of fields...
2
by: Patrick Blackman | last post by:
How do you clean the Recent Projects listbox?
3
by: jcor | last post by:
Hi, I'm trying the "make distclean" comand. but I allways get this error: if I use the "make clean" I get the same error. Can someone teach me to use this commands, please? Thanks a lot, ...
0
by: Christopher | last post by:
How can I make a vc++ project erase its $(OutDir) upon using the clean command? I tryed Properties->Configuration Properties->General->Extensions to Delete on Clean Add $(ObjDir) And it...
4
by: wxPythoner | last post by:
To create a tuple with one element, you need to do this: <type 'tuple'> But if you do this <type 'int'> you don't get a tuple. I thought that just putting a value inside ( )
8
by: plenty900 | last post by:
Hello, I'm trying to build a large project, and I've found that when something doesn't compile properly, and I attempt to re-build it, Visual C++ Express doesn't make a new attempt. So then I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.