G
Guest
Hi,
I am primarily a Java developer well versed in the ways of Java AWT and
Swing but am relatively new to .NET GUI development.
I've been making a simple windows application using C# that basically allows
a user to enter some data then submit it to be processed by a task running on
a separate thread. When the task is done the form gets updated showing some
results. The problem I'm running into is trying to update the GUI components
in a safe way so that only one thread is doing the update... in others words
a GUI thread.
In the world of Java this is pretty easy to do. One very simple way is for
the task in the non-GUI thread to create a new object that inherits the
java.lang.Runnable interface and post it on the AWT Event Queue via the
SwingUtilities.invokeLater() method. Once posted the AWT Thread will
eventually consume and run that object so that it can update the GUI safely.
(Also note that all user activity is run on the AWT thread too).
Basically what I want to know is if .NET has an equivalent well known GUI
thread like in Java where you can post task that will eventually be run to
update the GUI safely. I've been going through various .NET books and the
MSDN site to find information, but the only details I can get is to use
proper synchronization techniques. I'm very knowledgeable about how to
develop multi-threaded applications, but I find the lack of a well known GUI
thread to update the UI a bit frustrating.
Maybe I'm missing something and haven't come across the right information
yet, but any help would be greatly appreciated.
Thanks,
Michael Cohen
Oculus Info, Inc.
I am primarily a Java developer well versed in the ways of Java AWT and
Swing but am relatively new to .NET GUI development.
I've been making a simple windows application using C# that basically allows
a user to enter some data then submit it to be processed by a task running on
a separate thread. When the task is done the form gets updated showing some
results. The problem I'm running into is trying to update the GUI components
in a safe way so that only one thread is doing the update... in others words
a GUI thread.
In the world of Java this is pretty easy to do. One very simple way is for
the task in the non-GUI thread to create a new object that inherits the
java.lang.Runnable interface and post it on the AWT Event Queue via the
SwingUtilities.invokeLater() method. Once posted the AWT Thread will
eventually consume and run that object so that it can update the GUI safely.
(Also note that all user activity is run on the AWT thread too).
Basically what I want to know is if .NET has an equivalent well known GUI
thread like in Java where you can post task that will eventually be run to
update the GUI safely. I've been going through various .NET books and the
MSDN site to find information, but the only details I can get is to use
proper synchronization techniques. I'm very knowledgeable about how to
develop multi-threaded applications, but I find the lack of a well known GUI
thread to update the UI a bit frustrating.
Maybe I'm missing something and haven't come across the right information
yet, but any help would be greatly appreciated.
Thanks,
Michael Cohen
Oculus Info, Inc.