J
JMecc
I am recieving data grom a DAQ card and each time to handle it I call
a BackgroundWorker such that the main thread can keep the UI
responsive. I don't need the UI to reflect changes many times per
second when new data comes in, only as fast as it can (but I do need
the new data to be added onto my data array).
Sometimes the new data coming in event tries to call the
BackgroundWorker while it is still handling the previous data entry
and calcs (& you can't start a BackgroundWorker while it is still
running), so I tried using:
While DataInBkgndWorker.IsBusy
System.Threading.Thread.Sleep(20)
End While
DataInBkgndWorker.RunWorkerAsync(pts)
but this ends up in an infinite loop when IsBusy is true.
I was thinking that while I pause the main thread for a few
milliseconds, the BackgroundWorker thread would finish and then the
main thread could call the BackgroundWorker again a few iterations
later. Instead the app fully freezes, using up 0% processor resources
(does nothing but while loop). How can I call the BackgroundWorkers
back-to-back without overlapping?
Jo
a BackgroundWorker such that the main thread can keep the UI
responsive. I don't need the UI to reflect changes many times per
second when new data comes in, only as fast as it can (but I do need
the new data to be added onto my data array).
Sometimes the new data coming in event tries to call the
BackgroundWorker while it is still handling the previous data entry
and calcs (& you can't start a BackgroundWorker while it is still
running), so I tried using:
While DataInBkgndWorker.IsBusy
System.Threading.Thread.Sleep(20)
End While
DataInBkgndWorker.RunWorkerAsync(pts)
but this ends up in an infinite loop when IsBusy is true.
I was thinking that while I pause the main thread for a few
milliseconds, the BackgroundWorker thread would finish and then the
main thread could call the BackgroundWorker again a few iterations
later. Instead the app fully freezes, using up 0% processor resources
(does nothing but while loop). How can I call the BackgroundWorkers
back-to-back without overlapping?
Jo