When I profile my C# application in Visual Studio 2010, in Line View, the 2nd highest time consuming function is listed as System.Windows.Forms.Application.DoEvents(). 7th on the list is System.Windows.Forms.Form.ShowDialog(). These two consume about 8% and 2.5% of the total exclusive samples.
The program does not have much user interaction. The user clicks a button and the application starts and runs its algorithms for about a minute, and then stops. During that period, there is no user interaction, however, there's heavy cpu and IO use.
I am not sure I understand why the above two functions (DoEvents and ShowDialog) capture so many exclusive samples. Is there anything that can be done for these two?
EDIT for Clarification: The application has 4 different threads. One thread reads data from an external device and places it in a queue. Another thread, reads data from the queue, and performs data manipulation. This cpu intensive thread places the manipulated data into another queue. The 3rd thread reads this queue and writes the data to disk in regular intervals. All threads are implemented as a backgroundWorker. The final (4th) thread is the applications main Form() itself. It actually is inactive during the whole process.