5 Replies - 1332 Views - Last Post: 08 August 2012 - 10:14 AM Rate Topic: -----

#1 shine a u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-August 12

application.exit() not working

Posted 08 August 2012 - 03:01 AM

Check This Code
private void form1_load(object sender,EventArgs e)
{
int i=o;
while (i<10)
{
if (connection()==1)
{
read_delete();
sendsms();
closing();//
}
else
{
messagebox.show("Error Conecting to Device","shine",messageboxbuttons.ok,messagebox.icon.Error);
Application.exit();
}
i=0+1; //for infinite Loop
}
}

Is This A Good Question/Topic? 0
  • +

Replies To: application.exit() not working

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: application.exit() not working

Posted 08 August 2012 - 03:05 AM

Cool.

What's the problem and what have you tried?

This post has been edited by RudiVisser: 08 August 2012 - 03:10 AM

Was This Post Helpful? 0
  • +
  • -

#3 shine a u  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-August 12

Re: application.exit() not working

Posted 08 August 2012 - 03:14 AM

I Am Trying To send and receive SMS through GSM/GPRS Modem.
Was This Post Helpful? 0
  • +
  • -

#4 Vishu Sukhdev  Icon User is offline

  • D.I.C Head

Reputation: 38
  • View blog
  • Posts: 150
  • Joined: 19-February 10

Re: application.exit() not working

Posted 08 August 2012 - 06:07 AM

You get message "Error Conecting to Device".
I think you should place break point on if condition and debug all your coding to see its working fine.
Was This Post Helpful? 1
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5481
  • View blog
  • Posts: 11,762
  • Joined: 02-June 10

Re: application.exit() not working

Posted 08 August 2012 - 07:14 AM

View PostRudiVisser, on 08 August 2012 - 04:05 AM, said:

What's the problem and what have you tried?



View Postshine a u, on 08 August 2012 - 04:14 AM, said:

I Am Trying To send and receive SMS through GSM/GPRS Modem.


What does that have to do with the title of your post: "application.exit()" not working?

Application.Exit() will work if it is ever reached. So it must be that it is not being reached.
You have an if condition that must be met, and even if it is you call three methods; any of which might break with an exception or just go into a loop and never return.

Vishu is right: You need to learn to debug.

shine a u: What this shows us is that you aren't familiar with breakpoints and how to debug your own code. Learning to debug one's own code is an essential skill. Sadly, one that apparently few college courses teach. Silly if you ask me.

Placing breakpoints and walking through the code line by line allows you to actually WATCH it execute.

Visualizing what your code does will let you see why it behaves the way it does.

It would be well worth your time to do the tutorials on FAQ 2. A couple hours learning this skill will save you hundreds of hours of confusion in one project alone.


See FAQ # 2. (Click the SHOW button below)



TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated July 2012
Spoiler



Was This Post Helpful? 1
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3553
  • View blog
  • Posts: 11,017
  • Joined: 05-May 12

Re: application.exit() not working

Posted 08 August 2012 - 10:14 AM

What do you mean Application.Exit() doesn't work? What were you expecting it to do?

If you were expecting it to terminate you program right there and then, you are sadly mistaken. To quote from MSDN (emphasis mine):

Quote

The Exit method stops all running message loops on all threads and closes all windows of the application. This method does not necessarily force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return.


In other words, .NET Framework Application.Exit() != C/C++ exit().
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1