I have a BackGroundWorker that pends on a WinUSB ReadPipe() call in DoWork(). When ReadPipe() returns data, that data is packaged into the DoWorkEventArgs parameter and DoWork() ends.
Usually RunWorkerCompleted() executes very soon after DoWork() ends. Every now and then, however, there is a 5 second delay between the two. I used DateTime.Now timestamps at the start and end of DoWork() and RunWorkerCompleted(), to determine exactly where the delay occurs.
What could be causing the delay between DoWork() and RunWorkerCompleted()? Is it anything that I can do something about?