tags:

views:

202

answers:

2

Is there any way to call a function in C# when the user exists the application?

I'm using Visual C# 2008 Express edition.

Thanks.

+4  A: 

It's a windows forms applications, isn't it? You can use this event:

System.Windows.Forms.Application.ApplicationExit += ...
Cristian Libardo
Working from memory, there is a similar concept in WPF.
Daniel Paull
A: 

I've never tried it so this may be a shot in the dark, but couldn't one override the default exit method and do something like protected override exit {myMethod(); base(e);} Though I'm assuming delegation does essentially the same thing in this case

edude05