Results 1 to 5 of 5

Thread: Application.Exit after catch exception cause the app hangs

  1. #1

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Application.Exit after catch exception cause the app hangs

    good day guys,

    i came to this problem and i've googled it but i couldn't get any answer. i got an app, which connect to sql server 2000, im using try catch method in any sql event (select, insert, etc). so if the server is down, then i catch the exception and throw to a messagebox, after that Application.Exit. but the app hangs and doesn't exit the system.

    any idea?
    *wink wink*

    _babyekc

  2. #2
    Member
    Join Date
    Jan 2008
    Posts
    33

    Re: Application.Exit after catch exception cause the app hangs

    it would be easier to diagnose if we could see some code...

  3. #3
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Application.Exit after catch exception cause the app hangs

    Hi,
    don't attempt an insert etc if the device is not connected to the network then. If the IP address is 127.0.0.1 then the device is not connected, and warn the user they are out of range.

    The device is 'hanging' as it is trying to find the server

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  4. #4

    Thread Starter
    Hyperactive Member babyekc's Avatar
    Join Date
    Jul 2004
    Location
    planet earth
    Posts
    270

    Re: Application.Exit after catch exception cause the app hangs

    Code:
    public void UpdateSomething(string serialCardNo, string drinkID)
    		{
    			try
    			{
    				SqlConnection sqlConn = new SqlConnection(Global.ConnectionString);
    				sqlConn.Open();
    											
    				SqlCommand sqlCmd = new SqlCommand("UPDATE_SOMETHING_SP",sqlConn);			
    				sqlCmd.CommandType = CommandType.StoredProcedure;					
    								
    				sqlCmd.Parameters.Add(new SqlParameter("@ABC", ABC));
    				sqlCmd.Parameters.Add(new SqlParameter("@DEF", DEF));
    								
    				sqlCmd.ExecuteNonQuery();
    
    				sqlCmd = null;
    				sqlConn.Close();
    			}
    			catch
    			{
    				MessageBox.Show("Couldn't connect to the server. Please check the network. Application will be terminated!");
                                                       Application.Exit();
    			}
    		}
    nevermind of the exception message. the application hangs in Application.Exit();
    *wink wink*

    _babyekc

  5. #5
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Application.Exit after catch exception cause the app hangs

    Hi,
    as I say, test for network connectivity before starting the operation

    Pete
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

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