Click to See Complete Forum and Search --> : [RESOLVED] Stopping Prozess of a Backgroundworker
JonnyPoet
February 2nd, 2009, 05:03 PM
Hi !
I'm loading lots of Data into a DataTable with 10.000 ds of records.
So this needs a while I'm using DataAdapter and DataTable. All this is done in a backgroundprozess.
Now I want to be able to stop for example when the user decides to stop it by closing the form or by closing the application. I know stopping the backgroundworker could be done simple by calling the backgroundworker to Cncel async. But this canclation is pending as long as the dataAdapter still fills the table.
The question is: How can I stop the DataAdapter filling a table in a backgroundprozess.
Thx for any hints
dglienna
February 2nd, 2009, 09:34 PM
Why do you need to return 10K records :eek:
I hope you don't expect the user to look at that many records of ANYTHING!
JonnyPoet
February 3rd, 2009, 02:41 AM
Why do you need to return 10K records :eek:
I hope you don't expect the user to look at that many records of ANYTHING!
No I want to have all the data offline on each pc and then only sending actualisations between the database and the clients. ( One Client actualizes data, the server responds an actualization to the program which should actualize his DataTable and if needed his actual screen (all again in the background) So I need to load the full table. which can need a minute maybe. But just because its a backgroundprocess how to secure what happens if the user decides to stop and closes the program before it is ready.
I dont want to have a lost backgroundthread still running some minutes after the user has decided to kill the application.
This is one scenario
The other one is and this is where I'm just working on an automatic running dataupdate process where I read and rewrite data between different sources to a table. This contains lots of comparing actions and leads in the end to a process that all together neeeds maybe half an hour. Therefor I want to be able to stop whenever I want and to continue at the point where I have stopped.
No problem if I do not use DataSet and DataTable and do reading and writing simple myself using AdoDbReader. Because here I have access to each row. But I'm frightened this will slow down the full process. Or do you think reading and writing lots of data is quicker using the AdoDbReader instead of the DataAdapter, DataTable, DataSet and all this ? I never tested :D this.
BTW I just looked its approximate 30.000 Records to work on and because of its so much work I want to do it in a backgroundprocess.Some few of them ( maybe 100 cannot be updated automatically and this are to be found out during this process and are going to a list shown on the screen )
Mutant_Fruit
February 3rd, 2009, 03:08 AM
I'm frightened this will slow down the full process. Or do you think reading and writing lots of data is quicker using the AdoDbReader instead of the DataAdapter, DataTable, DataSet and all this ? I never tested this.
You've never tested it, so why are you frightened it'd be too slow? Nothing is too slow until it's benchmarked. Test it. It'll allow you to abort your loading, so even if it's 20% slower, that's not such a bad thing. Alternatively you could try returning the data in chunks of 1000 rows (or whatever).
JonnyPoet
February 3rd, 2009, 09:29 AM
You've never tested it, so why are you frightened it'd be too slow? Nothing is too slow until it's benchmarked. Thats true. But your next statement
Alternatively you could try returning the data in chunks of 1000 rows (or whatever).This is bought !! we would say in German. This is simple brilliant. The idea of ideas :thumb: Jump. Great ! Easy to do, no big programming effort only a simple sql query change in the 'Where' section. Handling the primary key so very quick too IMHO and here I easily can test whats the best way to do: 500 rows, 1000 rows. whatever. Then if this will slow down I can alternatively try to do a code running with the Reader. But this will be the very last option, because it would need a lot of additional work.
Thx a lot
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.