简体   繁体   中英

C# threads communication problem

I have to resolve problem which in simple way could be like:

  1. GUI app with Buttons start/stop (start/stop starts/stops the threads) and multiline textbox
  2. 2 independent threads which do: THREAD A (Separated calss): runs in loop and generates random numbers in interval 1..20 with 150ms delay. When is generated odd number, then is sent to mainform where is received multiplied by 100 and result added to the textbox on form. Please, any help, simple code or whatever - or link where to study how to write it, I'm totally newbie in C#

You should use the Control's BeginInvoke method to marshal data from a background thread to the main thread and update the textBox's properties. You will find an example similar to your task at:

Writing to a TextBox from another thread?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM