I have a C# winforms app in which I am calling a method on a different
thread, using the Thread.Start() method. The method that is being
executed on the new thread attempts to make a button visible and a
panel visible after doing some work asynchronously. The button and
panel are private to the form that contains both the method that
starts the new thread (i.e. the calling method) and the method that
the new thread executes. While debugging, and just before exiting from
the new thread method call, I can see that the button visible property
is true and the panel visible property is true, however when the form
finally renders, neither of the controls can be seen. Moreover, I have
verified that the visible property of the panel is true and executed
the BringToFront method of the panel after the form renders. The form
window handle of the calling method is the same as that of the method
executed on the new thread.
I am pretty sure that the new thread is operating on the same form
object/instance as the calling thread since I can successfully modify
the background color (I see the color change on the screen) of the
calling form and I can close the calling form from within the method
that is executed on the new thread.
Interestingly, if the button and panel do not initially have visible =
false, I have no problems setting the visibility to false and back to
true.
I can supply code if desired.
I am absolutely baffled by this.
TIA
Shaun 4 4322
Hi,
Any updates to the UI must be done through the main thread (often called the UI thread).
For an example of how to do this, see http://www.codeproject.com/csharp/winformthreading.asp
-----------
Robert Jeppesen
robert.jeppesen%at%durius-dot-se
"Confused White Guy" <sh*********@hotmail.com> wrote in message news:9b**************************@posting.google.c om... I have a C# winforms app in which I am calling a method on a different thread, using the Thread.Start() method. The method that is being executed on the new thread attempts to make a button visible and a panel visible after doing some work asynchronously. The button and panel are private to the form that contains both the method that starts the new thread (i.e. the calling method) and the method that the new thread executes. While debugging, and just before exiting from the new thread method call, I can see that the button visible property is true and the panel visible property is true, however when the form finally renders, neither of the controls can be seen. Moreover, I have verified that the visible property of the panel is true and executed the BringToFront method of the panel after the form renders. The form window handle of the calling method is the same as that of the method executed on the new thread.
I am pretty sure that the new thread is operating on the same form object/instance as the calling thread since I can successfully modify the background color (I see the color change on the screen) of the calling form and I can close the calling form from within the method that is executed on the new thread.
Interestingly, if the button and panel do not initially have visible = false, I have no problems setting the visibility to false and back to true.
I can supply code if desired.
I am absolutely baffled by this.
TIA
Shaun
I'm surprised this isn't blowing up all over the place, you must be running
on an NT box.
You've violated a major threading rule here. Thou shall have no other Gods
but me...oops sorry (that was meant for the preacher in here)
Thou shall not modify UI objects with a child thread, only the main thread.
"Confused White Guy" <sh*********@hotmail.com> wrote in message
news:9b**************************@posting.google.c om... I have a C# winforms app in which I am calling a method on a different thread, using the Thread.Start() method. The method that is being executed on the new thread attempts to make a button visible and a panel visible after doing some work asynchronously. The button and panel are private to the form that contains both the method that starts the new thread (i.e. the calling method) and the method that the new thread executes. While debugging, and just before exiting from the new thread method call, I can see that the button visible property is true and the panel visible property is true, however when the form finally renders, neither of the controls can be seen. Moreover, I have verified that the visible property of the panel is true and executed the BringToFront method of the panel after the form renders. The form window handle of the calling method is the same as that of the method executed on the new thread.
I am pretty sure that the new thread is operating on the same form object/instance as the calling thread since I can successfully modify the background color (I see the color change on the screen) of the calling form and I can close the calling form from within the method that is executed on the new thread.
Interestingly, if the button and panel do not initially have visible = false, I have no problems setting the visibility to false and back to true.
I can supply code if desired.
I am absolutely baffled by this.
TIA
Shaun
Alvin Bruney <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote:
<snip> You've violated a major threading rule here. Thou shall have no other Gods but me...oops sorry (that was meant for the preacher in here)
<snip>
I'm not sure what it says about me that my first reaction to that
wasn't to think of my preaching, but to think of the pilot episode of
the West Wing...
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
ha ha i was trying to be as subtle as possible, but you caught on.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Alvin Bruney <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote:
<snip>
You've violated a major threading rule here. Thou shall have no other
Gods but me...oops sorry (that was meant for the preacher in here)
<snip>
I'm not sure what it says about me that my first reaction to that wasn't to think of my preaching, but to think of the pilot episode of the West Wing...
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Zuel |
last post by:
Sup everyone!
I wrote this code for Tomcat appserver but I am told from an
associate that it has threading issues. The basic idea is to store a
read only data table for everyone to use. It...
|
by: Jon Skeet [C# MVP] |
last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the
article on all the groups this is posted to.
I've finally managed to finish my article on multi-threading - at least
for...
|
by: Danny J. Lesandrini |
last post by:
The following code works with a standard MDB to navigate
to a particluar record (with a DAO recordset, of course)
but it's giving me problems in an ADP I'm working on.
Dim rs As ADODB.Recordset...
|
by: Ludovic SOEUR |
last post by:
Have everyone tried to create controls in separated threads ? I have a
problem that I do not understand.
To simplify the explanations, I wrote theses few lines to show an example of
the problem....
|
by: Keith Mills |
last post by:
Hello, please find attached a basic outline of what I am attempting to
accomplish... basically I want to create a number of THREADS (which I can do
fine), but I then need a method for them to be...
|
by: Toe Dipper |
last post by:
In short we have a lengthy process when a form is loaded that adds
activex controls to our windows form. This process in itself works
fine however we would like to push this processing to a thread...
|
by: SyGC |
last post by:
Hi Guys,
I have used Threading for Network.Ping to continuously ping an IP address if ping is successful Image A is displayed if not Image B. The code is as follows:
Imports System
Imports...
|
by: Dann Corbit |
last post by:
Rather than create a new way of doing things:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html
why not just pick up ACE into the existing standard:...
|
by: tshad |
last post by:
I have a Windows App that is doing some work and then writing a "Now
Processing..." line to the status line of the window as well as the Textbox
on the form.
But the problem is that the work is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |