Results 1 to 9 of 9

Thread: [2008] On Program Crashing Do Something??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    [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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Re: [2008] On Program Crashing Do Something??

    could u please give me an example?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Addicted Member
    Join Date
    Jul 2007
    Posts
    159

    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

  6. #6
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2008] On Program Crashing Do Something??

    Quote 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.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Re: [2008] On Program Crashing Do Something??

    where do i put this code?

  8. #8
    Addicted Member
    Join Date
    Jul 2007
    Posts
    159

    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.

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] On Program Crashing Do Something??

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width