Hallo everyone.
I'm a beginner at VB.NET but I got an task to resolve and I find it very interesting, therefore would like to learn more about this. I hope some of you guys can help me understand this.
Here is the situation...
(To make it simple, I'll get directly to my problem, and that is serialport communication.)

I have a program that reads UID from RFID Tags and if neccesary programs them (about 10 Tags per second - if only read performed / 2 Tags per second - if programming needed)
So you can assume that the main key here is fast and reliable communication.
Main problem is that serial port DataReceived event handler is fired (in my oppinion) uncontroled and every time differently. Sometimes I get 3 bytes and right after that another 13, sometimes I get 8 bytes and right after another 8 received and so on. ( I think that you all are familiar with this problem)



1. What would you recommend me, to declare COM port in another class or to keep it in the main Form class? I wanted to separate Main Class and SerialPort Class because of threading and invoking. i noticed that if DataReceived is in Main class, and I try to invoke something else from it, the Main class frezzes for a few ms. Or did I get it wrong. The main thing is, I want to have full control of everything what is happening at any time. As I said, when I need only to read UID from the Tags, there is about 10 Tags per second going through the reader. I can not afford that the SerialPort Data Received Event handler sends me partial UID (3 or 4 or 5 bytes and after that the rest)...

2. If I declare serialport in another class, how can I open that port from Main Class?`(I don't quite understand this Private Public Shared Protected.. Classes) All I know is that I am not able to declare serial port in shared class, but if I declare it in another type of class, I can not access it from Main class...

3. What's the best way to communicate with serialport? I need to send string to it ( I do it by sending an Byte Array ) and also to read bytes from it ( I read Byte by Byte ). But as I already mentioned, I need to receive the whole UID or the whole response from the tag. The good thing is that I know exactly at any moment how many bytes I'm expecting to receive (Maybe we can use that somehow - but not using Threshold )

I'll gladly provide my code here if you need it, but I wanted to build it again from Ground Zero, and to build it clean and correct.
Any advice is appreciated. If you have any links or tutorials about SerialPorts or asynchronous threads or something like that you can write it down in comments.
Thanks a lot in advance..