|
-
Jan 6th, 2008, 06:37 AM
#1
Thread Starter
Addicted Member
[2008] On Program Crashing Do Something??
Im building an IRC Client, but Im having a problem, if my client crashes or I stop it without sending the msg QUIT to the server, the server still thinks im connected (until it sends the PING)
anyway, is there anyway to send the QUIT msg before crashing?
like if program is about to crash send QUIT msg ???
:S
thanks for help
-
Jan 6th, 2008, 06:53 AM
#2
Re: [2008] On Program Crashing Do Something??
Handle the UnhandledException event of the application. Note that this event is not raised while debugging because the debugger itself handles unhandled exceptions, but it will be in a Release build.
-
Jan 6th, 2008, 07:08 AM
#3
Thread Starter
Addicted Member
Re: [2008] On Program Crashing Do Something??
could u please give me an example?
-
Jan 6th, 2008, 07:15 AM
#4
Re: [2008] On Program Crashing Do Something??
You don't need me to do it for you when you have access to the MSDN Library. Microsoft has already provided all the information you need. This was one of the first results returned by a search for unhandledexception event. My advice to you, as to everyone else, is to try for yourself first, then ask if you're unable. If you haven't consulted the MSDN Library for a question relating to .NET development then you haven't really done all you can.
-
Jan 6th, 2008, 02:11 PM
#5
Addicted Member
Re: [2008] On Program Crashing Do Something??
This is probably not a good way to do it but i used this a while back when i made a tcpServer. Just add whatever from the code below on the main form's formclosing event:
Code:
Select Case e.CloseReason
Case CloseReason.ApplicationExitCall
'send quit
Case CloseReason.FormOwnerClosing
'send quit
Case CloseReason.MdiFormClosing
'send quit
Case CloseReason.None
'send quit
Case CloseReason.TaskManagerClosing
'send quit
Case CloseReason.UserClosing
'send quit
Case CloseReason.WindowsShutDown
'send quit
End Select
-
Jan 6th, 2008, 02:15 PM
#6
Hyperactive Member
Re: [2008] On Program Crashing Do Something??
 Originally Posted by ^^vampire^^
This is probably not a good way to do it but i used this a while back when i made a tcpServer. Just add whatever from the code below on the main form's formclosing event:
Code:
Select Case e.CloseReason
Case CloseReason.ApplicationExitCall
'send quit
Case CloseReason.FormOwnerClosing
'send quit
Case CloseReason.MdiFormClosing
'send quit
Case CloseReason.None
'send quit
Case CloseReason.TaskManagerClosing
'send quit
Case CloseReason.UserClosing
'send quit
Case CloseReason.WindowsShutDown
'send quit
End Select
Why you use select case, if you want to send quit in all cases?
Select Case e.CloseReason
When CloseReason doesn't matter 
The question is: "How to notice, if the app. closed"
Last edited by Ivenesco; Jan 6th, 2008 at 02:18 PM.
-
Jan 6th, 2008, 02:24 PM
#7
Thread Starter
Addicted Member
Re: [2008] On Program Crashing Do Something??
where do i put this code?
-
Jan 6th, 2008, 02:57 PM
#8
Addicted Member
Re: [2008] On Program Crashing Do Something??
Wow... i wasn't even thinking when i posted that one... ignore me i've gone crazy... thats more for specifying different methods for different close reasons... my bad!
Anyway for your main form in the FormClosing event add the code to send quit text. Not quite sure if that will work properly but i seem to have gotten good results from it.
-
Jan 6th, 2008, 06:25 PM
#9
Re: [2008] On Program Crashing Do Something??
 Originally Posted by perito
where do i put this code?
Did you follow the link I provided? It provides SPECIFIC instructions for handling the UnhandledException event.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|