Click here to Skip to main content
15,894,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys!

I have a program that uses some threads at the same time that retrieve a page, wait for response, parse the response and then save the data in a DB using Sqlite.

Now when i want to close my program and there are these threads running it takes some time so it closes. how can i abort the page retrieval or the DB update/insert when i need to close my program, quickly?
Posted
Updated 14-Jul-11 7:02am
v3

Use the asynchronous reader execute methods (BeginExecuteReader/EndExecuteReader instead of ExecuteReader, for instance).
 
Share this answer
 
Comments
manchukuo 14-Jul-11 12:19pm    
oh i forgot i am using sqllite
I would say hide the form until the operation is completed and then close it. This would be adequate if the wait is at most a few seconds and then intend is to make it appears responsive...

BackgroundWorker can also be used and cancelled... Assuming that you can check for cancellation often enought, then the background task would be cancelled soon.

If you have a single long operation, then you might consider splitting that operation into multiple ones...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900