creating dialogs
-
Hi, In my WinForm App, I have a blocking call to dll that takes a while to return. I want to indicate the user to wait, probably by showing an animated gif or progress bar. I dont want to go into threading. Is there any other way to do this. I created another form that looks like small dialog with the animated gif and text box.I changed the FormBorderStyle property to FixedDialog. I called it from my form as
WaitDialog WaitD = new WaitDialog(this); WaitD.Show(); ////blocking call to DLL... WaitD.Dispose();
What happens is, it shows the wait form, but none of its controls ( the animated gif and text box) is shown. I get a blank white boxes in their places. What should I do. Any ideas. Thanks in advance. -- modified at 15:10 Tuesday 28th February, 2006 -
Hi, In my WinForm App, I have a blocking call to dll that takes a while to return. I want to indicate the user to wait, probably by showing an animated gif or progress bar. I dont want to go into threading. Is there any other way to do this. I created another form that looks like small dialog with the animated gif and text box.I changed the FormBorderStyle property to FixedDialog. I called it from my form as
WaitDialog WaitD = new WaitDialog(this); WaitD.Show(); ////blocking call to DLL... WaitD.Dispose();
What happens is, it shows the wait form, but none of its controls ( the animated gif and text box) is shown. I get a blank white boxes in their places. What should I do. Any ideas. Thanks in advance. -- modified at 15:10 Tuesday 28th February, 2006Manu_81 wrote:
a while to return. I want t
A blocking call is a blocking call, there's really no way around this. Once your UI thread makes the blocking call to your dll, you're stuck in that you cannot update your form. You *could* pass your form instance into the blocking call, and have the blocking call call form.Update or Application.DoEvents(), but that's sounding more like a hack than anything. What's wrong with threading for this?
-
Manu_81 wrote:
a while to return. I want t
A blocking call is a blocking call, there's really no way around this. Once your UI thread makes the blocking call to your dll, you're stuck in that you cannot update your form. You *could* pass your form instance into the blocking call, and have the blocking call call form.Update or Application.DoEvents(), but that's sounding more like a hack than anything. What's wrong with threading for this?
Apart from the blocking call, I also call various other functions from the dll and display the return results to the user. So if I do thread, that would be like updating the UI inside this thread, which I dont want to do. I also want to avoid thread for this, as my app uses some threads in different places. I just dont want to use so many threads in my app... So there is no way to get around this??? -- modified at 15:49 Tuesday 28th February, 2006
-
Apart from the blocking call, I also call various other functions from the dll and display the return results to the user. So if I do thread, that would be like updating the UI inside this thread, which I dont want to do. I also want to avoid thread for this, as my app uses some threads in different places. I just dont want to use so many threads in my app... So there is no way to get around this??? -- modified at 15:49 Tuesday 28th February, 2006
Manu_81 wrote:
I just dont want to use so many threads in my app...
Threads are a good thing. They allow you to utilize multi-core and multi-processor machines far more than a single-threaded application would. They also keep your UI thread responsive, which end-users will praise you for. I recommend that your DLL do its heavy lifting on another thread. While that thread is running, have the dll just display a "loading..." or "please wait..." dialog of some kind. Then, when the thread is finished, return the results to the UI thread for display to the user. You can use the BackgroundWorker[^] class to help you do this in a simple manner. The only other option would be to make a call to .Update() your form from your dll or call Application.DoEvents. However, there are caveats and gotchas associated with those solutions; the best solution is to do heavy lifting on a background thread.