Reputation: 850
I have a C# Winforms UI that makes a call to a COM object to derive some data.
I want a progress bar on the UI to cycle in order to indicate that work is in progress. Problem is that the COM call is synchronous, so processing waits for the COM call to complete and thus the progress bar cycling code does not get called.
Should I: 1. Make the COM call asynch to allow the progress bar code to cycle? 2. Use a second thread to run the progress bar (will this work or will the UI thread still be hung up on the COM call and thus not refresh the progress bar?) 3. some cleverer method?
Upvotes: 0
Views: 62
Reputation: 1505
You should create separate thread for execution of method call which takes time. Until it returns required data, show progress bar on your UI thread. This should work fine.
i.e. You should select first option from suggested three.
Upvotes: 1