473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I update a control from another thread?

Hello all,
I have read a lot about that I can't do something like

TextBox1.text ="abc"

if I am not in the gui thread. Can someone explain what
I actually need to do?

Tia
Nov 21 '05 #1
2 1819
<guy> schrieb:
I have read a lot about that I can't do something like

TextBox1.text ="abc"

if I am not in the gui thread. Can someone explain what
I actually need to do?


Always show your forms in the app's main UI thread and use 'Control.Invoke'
to communicate in the thread -> UI direction:

Multithreading:

<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms08162002.asp>
<URL:http://msdn.microsoft.com/library/en-us/dnforms/html/winforms01232003.asp>

<URL:http://www.devx.com/dotnet/Article/11358/>

<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassInvokeTopic.asp >

Multithreading in Visual Basic .NET (Visual Basic Language Concepts)
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconthreadinginvisualbasic.asp>

Sample:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>

If you have any further questions, feel free to ask them.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
These examples are rather complicated. I will have to spend
a whole day just to understand how to calculate pi and this
misses the point. O.k. Can you please explain as breifly as
possible what I need to do (and why) in order to update
a textbox from a worker thread.
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Jason Jacob | last post by:
To all, I have a GUI program (use c#), and I have create a Thread for loading some bulk data, I also arrange the GUI program like this: 1) load a form showing "Wait for loading..." etc 2) a...
2
by: Julia | last post by:
Hi, I have an application which run 3 different thread. the main application display a window like a console window in VS.NET. I would like that each thread will write to this window details...
1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
2
by: Joe | last post by:
Is there a function where I can use in a long intensive loop that would allow the program to update the UI and allow some control of the UI. I remember using this in VB but I was wondering if...
5
by: Marc Gravell | last post by:
In the following example, the Bindings don't update the UI if the property change is triggered from the non-UI thread - see the async button - from the listbox contents (and observation) the change...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
3
by: rob | last post by:
I've got a couple stretches of code where I use a lot of CPU on various operations. Since this is happening in a loop at unrestriicted speed, some of the form controls do not update. (Actually...
8
by: Justin Rich | last post by:
So another simple question from me :) as im working away ive made a button that does a series of wonderful things.. and as it goes along it suppose to update a label to let the user know what...
5
by: dgleeson3 | last post by:
Hello all Yes I know its been done before, but something silly is killing me on this. I have the standard progress bar and worker thread scenario with progress of the worker thread being fed...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.