473,386 Members | 1,673 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,386 software developers and data experts.

Is multithreading the way to go?

Greetings,
This will be my first use of a multithreading application. I am attempting to create an application that will have a GUI for user input and configuration, communicate with a PLC via DDE or OPC communication, and communicate with a printer via serial communication.

For the PLC:
I will need to maintain a heartbeat (change a bit in the PLC every few seconds and wait up to 30 seconds to see it change back). Tags in the PLC will also be used as events for further actions.

For the printer:
I will need to check ink levels, and report an error to the user if low/none. I will need to increment my index once the printer says it processed the number.

For the GUI:
I will need to have COM configuration for the serial communication. I will have two user-entry fields (Manufacturer and Item Number) combined with the part index to create my serial number to send to the printer.

My main question would be this: Is this a type of application that it would be beneficial to use multithreading on?
If so, would I have a thread per device (GUI, PLC, Printer) or per separate communication I'm going to handle (PLC heartbeat, PLC tags, Printer, then main GUI)?
Feb 14 '11 #1

✓ answered by Jason Mortmer

Think of it this way, one thread per stream of data. There's no point having another thread running if you are going to handle two different interrupts. If you do that, you might aswell put it all in the single program thread.

4 2011
Any form of hardware interfacing will benefit greatly from multi-threading. This is because any data received from the hardware is not instant like normal calculations in a program. When hardware returns data to a PC, it uses Interrupt Request Lines (IRQs) which the device driver handles when they are triggered. Checking for hardware interrupts can be performed on another thread and this is my preferred way of doing it. It breaks up the program into manageable segments and eliminated the old method of constantly polling a device to see if it has any data. I haven't done any work with a printer but I have interfaced with hardware before, mainly ethernet, setting up a separate thread to listen for data coming through.
Feb 14 '11 #2
Thank you for the prompt reply. Would you set up a thread per type of data you are looking for, or per device? i.e. - Would it be beneficial to have my heartbeat with the PLC be managed on its own thread, or just add it on to the thread monitoring the PLC tags?
Feb 14 '11 #3
Think of it this way, one thread per stream of data. There's no point having another thread running if you are going to handle two different interrupts. If you do that, you might aswell put it all in the single program thread.
Feb 14 '11 #4
Great, thank you very much
Feb 14 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
9
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
55
by: Sam | last post by:
Hi, I have a serious issue using multithreading. A sample application showing my issue can be downloaded here: http://graphicsxp.free.fr/WindowsApplication11.zip The problem is that I need to...
5
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use...
2
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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 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.