Click here to Skip to main content
15,916,215 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How can I drop and recreate a default constraint using smo? Pin
bobishkindaguy15-Dec-09 14:12
bobishkindaguy15-Dec-09 14:12 
Questioncrazy COM idea Pin
srcarr25-Aug-09 12:04
srcarr25-Aug-09 12:04 
QuestionCode obfuscation Pin
koleraba25-Aug-09 11:09
koleraba25-Aug-09 11:09 
AnswerRe: Code obfuscation Pin
N a v a n e e t h25-Aug-09 20:04
N a v a n e e t h25-Aug-09 20:04 
QuestionWinXP Home Can't Use Subfolder as Source for Picture Pin
Hypermommy25-Aug-09 8:58
Hypermommy25-Aug-09 8:58 
AnswerRe: WinXP Home Can't Use Subfolder as Source for Picture Pin
Henry Minute26-Aug-09 5:08
Henry Minute26-Aug-09 5:08 
GeneralRe: WinXP Home Can't Use Subfolder as Source for Picture Pin
Hypermommy26-Aug-09 5:11
Hypermommy26-Aug-09 5:11 
GeneralRe: WinXP Home Can't Use Subfolder as Source for Picture Pin
Henry Minute26-Aug-09 5:19
Henry Minute26-Aug-09 5:19 
GeneralRe: WinXP Home Can't Use Subfolder as Source for Picture Pin
Hypermommy26-Aug-09 6:09
Hypermommy26-Aug-09 6:09 
QuestionInstall software microphone Pin
TripShock24-Aug-09 2:11
TripShock24-Aug-09 2:11 
QuestionWhy does backgroundworker complete event is fired in other thread, instead of the one started it? [modified] Pin
Carl00723-Aug-09 22:53
Carl00723-Aug-09 22:53 
AnswerRe: Why does backgroundworker complete event is fired in other thread, instead of the one started it? Pin
Alan N24-Aug-09 1:17
Alan N24-Aug-09 1:17 
AnswerRe: Why does backgroundworker complete event is fired in other thread, instead of the one started it? Pin
Luc Pattyn24-Aug-09 1:46
sitebuilderLuc Pattyn24-Aug-09 1:46 
AnswerRe: Why does backgroundworker complete event is fired in other thread, instead of the one started it? Pin
Luc Pattyn26-Aug-09 0:05
sitebuilderLuc Pattyn26-Aug-09 0:05 
QuestionGetting mscorlib.Authentication Failure error Pin
V K 223-Aug-09 21:13
V K 223-Aug-09 21:13 
QuestionVB.NET PropertyGrid Categories Pin
NFranks23-Aug-09 15:06
NFranks23-Aug-09 15:06 
AnswerRe: VB.NET PropertyGrid Categories Pin
0x3c023-Aug-09 21:00
0x3c023-Aug-09 21:00 
GeneralRe: VB.NET PropertyGrid Categories Pin
NFranks24-Aug-09 4:04
NFranks24-Aug-09 4:04 
General[SOLVED] VB.NET PropertyGrid Categories Pin
NFranks24-Aug-09 5:25
NFranks24-Aug-09 5:25 
QuestionTimeout Error While Taking Database Back-up using Code Pin
VikashGohil21-Aug-09 19:44
VikashGohil21-Aug-09 19:44 
QuestionHow to detect when an application is about to exit Pin
CodeBerserker21-Aug-09 15:30
CodeBerserker21-Aug-09 15:30 
Hello.

In my windows application I have a subclassed Form (MyWin) that is opened as a top level window with myWin.Show(). MyWin contains a RichTextBox where the user is supposed to type in text. When myWin is closed by the user the text is saved to a file. I implement this by overriding OnClosing in MyWin and save the text from the RichTextBox there. This works fine when the user explicitly close myWin. But since myWin isn’t the main window in the application myWin can be closed implicitly when the application exits. When this happends the overridden OnClosing function will not be called, so the text will not be saved in this case.

I have tried to add a delegate to Application.ApplicationExit and Application.ThreadExit from MyWin to save the text from there. But that doesn’t work because when these delegates are called the RichTextBox has already been destroyed and its Text field is empty. I want MyWin to be autonomous so I don’t want to be dependent on some Save function that must be called when the main window closes.

So, what I need is someway to detect when the application is about to close, something like Application.BeforeExit but I cannot find anyway to do this. I thought that if I could retrieve the main window in the application,from MyWin, I could add a delegate to its Closing event, but I cannot find any way to do this. I have searched and found Application.Current.MainWindow in PresentationFramework, which I don’t know what it is, but when I try to use this the Application.Current is always null.

So, if anyone knows how to detect when the application is about to be closed before anything is actually closed I would appreciate some help.

Regards
Peter
AnswerRe: How to detect when an application is about to exit [modified] Pin
Luc Pattyn21-Aug-09 16:17
sitebuilderLuc Pattyn21-Aug-09 16:17 
AnswerRe: How to detect when an application is about to exit Pin
VikashGohil21-Aug-09 22:05
VikashGohil21-Aug-09 22:05 
AnswerRe: How to detect when an application is about to exit Pin
Jack Vanderhorst22-Aug-09 12:02
Jack Vanderhorst22-Aug-09 12:02 
AnswerRe: How to detect when an application is about to exit Pin
qmartens22-Aug-09 19:01
qmartens22-Aug-09 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.