i want to create a protocol, for a communication between my computer and a microcontroller. The first thing I want to do is to send the size of the data. This is already working, so my Serial Connection is already working. After i sent the size of the data, the microcontroller should allocate some memory and send an acknowledge byte, so the computer program knows that he is ready for the actual Data. For receiving the byte on my Computer, i am using a Handler:
private void DataReceivedHandler(
object sender,
SerialDataReceivedEventArgs e)
Now the problem is, that i don't know how I get the received Data (acknowledge byte) from the Handler to my function, so I can continue with my communication and send the actual Data to the microcontroller.
Is it possible, to wait in a function until a Handler will be executed and then jump back to the function and use the data which was received in the Handler?
Thank you very much