Currently im working on an app that receives data from RFID card reader throu serial port. The data, afterwards the data should be sent by TCP/IP to a server.
I already have both thing working, but not at the same time. I can read ID from card, and i can also send some text to server. But i would like to ask you for suggestion, what would be the best solution for those two things working together.
At the moment i have TCP/IP usage and Serial usage in two classes. From main class im creating objects of both classes and starting a thread that reads data from serial port.
Should i try something like this?
In class i would create only serial usage object and call a thread that handles reading. Inside of that reading thread, i would call a new thread that would open TCP/IP connection and sent data that it has recieved from serial port.
Another somehow simlar approach would open both connections from main class, but it would start TCP/IP sending thread (throu already open connection) from serial port recieveing thread.
I dont have too much experience with threading, so thats why i ask for your help fellow software developers. Thanks! (if that would help, i could paste some parts of code here).
UPDATED:
Thats for the tip, i'll look closer into that what you suggested. I guess that is good idea, but as i said i dont have too much experience with threading. Would it work, if i would create separate threads in those classes, and they would both use same object, lets say object of class Message, i would create new object in a COM handling thread, and TCP/IP handling thread would use that object to send the data from it throu TCP/IP? Can i make a queue of objects of class Message just like i can do with List? Also, how do i pass that queue of objects created in one thread in class toanotherthread