|
-
Dec 3rd, 2003, 06:56 AM
#1
Thread Starter
Lively Member
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 
-
Dec 3rd, 2003, 07:29 AM
#2
Fanatic Member
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.
-
Dec 3rd, 2003, 07:37 AM
#3
Thread Starter
Lively Member
Thanks for the info.
Regards,
Steve.
Old divers never die, they just go down on old wrecks 
-
Dec 3rd, 2003, 08:43 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|