Hi,
My app needs to read a text file, compare the data to that already
stored in the DB and generate a text file of the differences.
The UI displays the text file data and the db data in a series of
Datagridviews.
Piclk a row in the text file master table dgv and the other dgvs move
to the appropriate records so you can eyeball the differences before
generating the difference file.
I have used a dataset that contains two 'arms'
The text file arm and the database arm.
BindingSources are used to make the dataset relationships available
to the code.
Works OK but when I feed it the full text file it takes a long time to
do the comparison work.
Profiling shows the most expensive part is moving through the dataset
with the bindingSource.Movenext.
So I figured that maybe using the threadpool to do the iteration and
comparison would speed things up.
Sort of
while(position + 1 < bindingSource.Count)
{
assign all the bindingsources and the dataset to a helperclass object
'u'
ThreadPool.QueueUserWorkItem(new WaitCallback (MyComparisionFunction),
u);
MasterBindingSource.MoveNext();
position++;
}
However the comparision code fails when it tries to get one of the
datarelaionships back from one of the bindingsources. "Relation not
found"
Intellisense indicates it is there but you can't argue with the
executing code.
Maybe it is lost in the casting from object to helper class .
Anyway I started to get the feeling that maybe my whole approach is
inefficient.
So before I go completely off into the weeds what is the general
opinion on how to handle this task?
I am starting to think that maybe two collections of widgets maybe the
way to go. Then use tree views instead of dgvs
textfile -Collection A.
db -Collection B. (one B widget for each widget in A)
for( int i =0;i<A.Count;i++)
{
if (A.items[i] != B.items[i]
AddtoDiffFile(A.Items[i])
}
Thanks
Bob