|
-
Jul 26th, 2010, 03:20 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Canceling async calls
Hi,
I'm using the MethodInvoker to set a background process to work.
That process can take quite an amount of time, so I want the user to be able to cancel that.
Now my worries are that if I use Application.Exit() it doesn't quit or that the thread is not cleaned up correctly.
Any thoughts on this?
Thanks.
Delete it. They just clutter threads anyway.
-
Jul 26th, 2010, 07:55 PM
#2
Re: Canceling async calls
If you set the IsBackground property of a Thread to True before you Start it, it will not prevent the application closing. If that's not enough information then you're going to have to provide us with more information, i.e. exactly what you're doing, including code.
-
Jul 27th, 2010, 06:51 AM
#3
Re: Canceling async calls
Ignore my comment.
I seem to have mixed up the use of a background process with the use of the BackgroundWorker process.
Appologies for the missinterpetation.
Last edited by Optional; Jul 27th, 2010 at 06:57 AM.
Kind Regards,
Optional
If you feel this post has helped in answering your question please return the favour and Rate this post.
If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.
VB6 - (DataGrid) Get the Row selected with the right mouse button
-
Aug 5th, 2010, 11:13 PM
#4
Re: Canceling async calls
Application.Exit() is the same as calling Abort() on a thread, so if you've got proper cleanup, you're fine (back - but Application.Exit() will throw a security exception on some restricted accounts (it did on my school computers) so you should just set IsBackground. Environment.Exit() is different, though...
-
Aug 14th, 2010, 04:26 PM
#5
PowerPoster
Re: Canceling async calls
Environment.Exit returns a number back to the process/OS.
It terminates the process with a number. IT also throws a Security Exception, depending on the account you are using and security setting configurations on the account or for applications and generally is used for console based apps (but not restricted to them)
The thread in question can continue to run unless you set the IsBackground property to true on the Thread object, as highlighted earlier on.
http://msdn.microsoft.com/en-us/libr...ackground.aspx for more information.
-
Aug 14th, 2010, 07:03 PM
#6
Re: Canceling async calls
Environment.Exit() also completely terminates every thread without raising the ThreadAbortException.
-
Aug 14th, 2010, 08:07 PM
#7
PowerPoster
Re: Canceling async calls
it is advisable to use the correct approach to exit your application rather than just "stabbing in the dark until you get it"
-
Aug 14th, 2010, 08:40 PM
#8
Re: Canceling async calls
Well, he's already got it.
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
|