How do I update a control from another thread?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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/e...SystemWindowsFormsControlClassInvokeTopic.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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top