Brainstorming on correct data handling on application exit or error
Hallo all,
I'm thinking about a good way to manage the execution ending of an application.
The application gets data and processes for eacht row found an http request. If this fails I update a value in the db, status = 2 (error) else status = 1.
Data that is fetched is updated by the stored procedure to status 9 (pending). So here I know exaclty the statues of my rows in the database when the process is done completely.
Now I would like a way that when we quit the application, by ctrl-c catch or simple ":q" readline that the application quits only after the current running http request is not done (if there is one) and that this triggers an event that sets the status of this and all other data in the que back to status 0 (new).
I could go the way of a thread and watches the status of a thead before doing my end event ?
Any ideas ?
Red GoblinPosted Nov 23, 2009, 5:24 AM
Do I put all my http request and SqlDataReader logic in the background worker ? Is it possible to read the data in the reader and call for each row RunWorkerAsync ?
Red GoblinPosted Nov 19, 2009, 9:02 AM
Nilanka DharmadasaPosted Nov 19, 2009, 7:44 AM
I think, you should use a separate thread to process http requests and updata the DB accordingly. So main thread will look after the UI. When the user tries to close the application, main thread will inform the other thread, so the other thread can finish the current http request and update the DB with value 0 for other rows and finish the thread without contnuing with other http requests.
This can be easily done with background worker componenet. If you can paste your code here, I can help you to change your code.