J
Jon Brunson
I've got a worker thread which tells the GUI to update a progress bar as
it's updating records in a database (10,000+ records). I tried the
following methods, but none of them work quite right. Any other ideas?
1) Invoke - halts the worker thread while waiting for the GUI thread to
pickup the Invoke, which can cause a dead-lock situation (eg. the GUI
thread attempts to read from the db that the worker thread has locked
(Threading.Monitor) while it is updating)
2) Third thread - using a third thread to do the invoking doesn't work,
as the worker thread creates loads of them, and the execute out of
sequence, causing the progress bar's value to move about erratically)
3) GUI Timer - Have an object which holds the status of the update (eg,
the percentage complete) which the worker thread updates, and the GUI
thread reads from by means of a timer on a form - causes an overhead on
the GUI thread, and only get executed when nothing else on the GUI
thread is happening, which can cause the progress bar to not move for a
while, then jump up a long way.
it's updating records in a database (10,000+ records). I tried the
following methods, but none of them work quite right. Any other ideas?
1) Invoke - halts the worker thread while waiting for the GUI thread to
pickup the Invoke, which can cause a dead-lock situation (eg. the GUI
thread attempts to read from the db that the worker thread has locked
(Threading.Monitor) while it is updating)
2) Third thread - using a third thread to do the invoking doesn't work,
as the worker thread creates loads of them, and the execute out of
sequence, causing the progress bar's value to move about erratically)
3) GUI Timer - Have an object which holds the status of the update (eg,
the percentage complete) which the worker thread updates, and the GUI
thread reads from by means of a timer on a form - causes an overhead on
the GUI thread, and only get executed when nothing else on the GUI
thread is happening, which can cause the progress bar to not move for a
while, then jump up a long way.