A
Alexander
Hi, I have written a program that takes on some operations much more
time than I expected. As I have seen users clicking wildly on the
screen to make something happen, I want to follow the microsoft
principles: always show them something
First I made up a little status dialog containing a gif image to show
a little animation and a TextBox for a changing status message during
the work of the main program.
Just showing the dialog box (Form) at the start of the lengthy
operation does not work, as the dialog box is of course frozen because
it cannot work while the main message loop is stalled at the call of
the first method. Most solutions work with a non UI worker thread
which signals its status of the work progress to the UI thread. As my
main program is a UI program and all classes in there interact very
close it would be difficult for me to seperate a non UI thread for the
work. My idea was now to create a thread which shows the dialog and I
signal a new status message to the thread from my main UI thread
during the work, while disabling all inputs to the main window and
showing the status dialog topmost.
How would I do something like that?
I guess I just start the dialog by opening the dialog form with
Application.Run(new Statusdialog()) in the worker function of my
thread. But how do I access the dialog to signal new messages to it?
There is only one status dialog shown at a time so there is only one
instance of the dialog. I could create a static instance variable with
an access function in the dialog class to access the instance
following the singleton pattern. But from my experience with C++ this
is an unsafe way and I should use messages for the communication or
does C# have a synchronized keyword like Java to make such calls
thread safe?
Thanks for any help or suggestions,
Alexander
time than I expected. As I have seen users clicking wildly on the
screen to make something happen, I want to follow the microsoft
principles: always show them something

First I made up a little status dialog containing a gif image to show
a little animation and a TextBox for a changing status message during
the work of the main program.
Just showing the dialog box (Form) at the start of the lengthy
operation does not work, as the dialog box is of course frozen because
it cannot work while the main message loop is stalled at the call of
the first method. Most solutions work with a non UI worker thread
which signals its status of the work progress to the UI thread. As my
main program is a UI program and all classes in there interact very
close it would be difficult for me to seperate a non UI thread for the
work. My idea was now to create a thread which shows the dialog and I
signal a new status message to the thread from my main UI thread
during the work, while disabling all inputs to the main window and
showing the status dialog topmost.
How would I do something like that?
I guess I just start the dialog by opening the dialog form with
Application.Run(new Statusdialog()) in the worker function of my
thread. But how do I access the dialog to signal new messages to it?
There is only one status dialog shown at a time so there is only one
instance of the dialog. I could create a static instance variable with
an access function in the dialog class to access the instance
following the singleton pattern. But from my experience with C++ this
is an unsafe way and I should use messages for the communication or
does C# have a synchronized keyword like Java to make such calls
thread safe?
Thanks for any help or suggestions,
Alexander