Need advice on VB.Net multithreading options

Good afternoon,

I get damn time figuring out which multi-threaded approach to use in my current working project. Since I never wrote a multi-threaded application in my life, this is all confusing and very overwhelming. Without further ado, here is my background:

I am tasked with taking over the management application for a piece of test equipment in my company's R&D lab. The program should be able to send and receive serial communication with three different devices at the same time. The original program was written in VB 6 (without multithreading), and I planned to simply modify it to work with newer products that need to be tested until there is a security risk when closing the user interface due to excessive serial communication during the test. This led to the fact that part of the hardware was tested, so I decided to try to rewrite the application in VB.Net, since it was more convenient for me, and because I thought that multithreading could help solve this problem.

My plan was to send commands to other pieces of equipment from the main application thread and wring the receiving ends into their own threads, so that the main thread does not block when the time is critical. However, I still do not agree with my options. To add to my problems, I need to display the received messages in separate rich text fields, since they are received, while the data from one particular device should be analyzed by the main program, but only the text that is the result of the most recent test (I need to the text field contained all the data received).

, BackgroundWorkers. , . , , ? , , - , . BackgroundWorkers, , , , .

, , , . ? , ?

, , , , , ! // . , . , , !

+3
1

OK, , , , RichTextBox, , .

" " processControl?

, , , , / , (. BlockingCollection). /, .

'comms' . "command", , , , . "", , . A 'bool loadChar (char inChar)', char -by- char, 'true' , , . string textify(), . . 'errorMess' Exception.

, , comms - . , comms - . BeginInvoked GUI .

serialPort serialPort. , DataReceived , args a char comms.loadChar(). loadChar true, comms Block MachineCollection -, . - comms , . , - , , loadChar, .

state-machine (), , comms. SM - , BeginInvoke GUI , 'displaySomeStuff'. GUI , case-switch , , / .

, , . "comms", comms . BlockingCollection ( ), BeginInvoke() GUI.

. . , . , .

- "Thread.Join()".

+4

All Articles