Results 1 to 4 of 4

Thread: End statement in VB.Net 2003

  1. #1

    Thread Starter
    Lively Member Steve Cain's Avatar
    Join Date
    Sep 2000
    Location
    Wiltshire, UK
    Posts
    105

    Question End statement in VB.Net 2003

    Can anyone please tell me how to exit a program, using an Exit button, written for a Smart Device in VB.net 2003?

    The 'END' statement (without any additional keywords) is not supported. It is OK for a Windows application i.e. inserting 'END' into a buttons click event, but it doesn't work for a Smart Device application.

    Any comments welcome.

    Thanks.
    Old divers never die, they just go down on old wrecks

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    You can try these:

    Application.Exit()- This method stops threads and closes all windows of the application. It does not force the application to exit – in other words, it does not cause Application.Run to return. Instead, by stopping all threads and closing all windows, the application will “die” naturally as there is no more code to execute. Microsoft labels this as the preferred method to exit an application (in most cases).

    Application.ExitThread() - This method stops the current thread only.

    Environment.Exit(-1) – This method terminates the process (or app) and gives the underlying operating system the specified exit code (-1 in this example which I think is error)

    System.Threading.Thread.CurrentThread.Abort() – This method raises a ThreadAbortException in the thread on which it is invoked, and starts the process of terminating the thread. So, calling this method will terminate the current thread. As you might be thinking, this is not the best way to end an application because the application could have more than one thread running.

  3. #3

    Thread Starter
    Lively Member Steve Cain's Avatar
    Join Date
    Sep 2000
    Location
    Wiltshire, UK
    Posts
    105
    Thanks for the info.

    Regards,

    Steve.
    Old divers never die, they just go down on old wrecks

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: End statement in VB.Net 2003

    Originally posted by Steve Cain
    It is OK for a Windows application i.e. inserting 'END' into a buttons click event
    no it isn't!

    Yes "End" works, but it doesn't unload objects or free memory. Not clearing up properly is very bad - if you dont do it then repeatedly running your application will cause the system to slow down & maybe even crash.

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