0

How does serial port interrupt handler work?

Imagine that you are using an interrupt handler for serial port just like this

Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Background,
new System.Action(() =>
{
  dosthwith(serial port.ReadExisting());
}

and while doing something with the existing data in the buffer another data arrives and the handler is called again. I want to know how these thing work? Are they two different functions that working just like two threads or what ?

1
  • 1
    An interrupt handler lives inside a device driver. Nothing like that in your snippet, the ReadExisting() call simply reads whatever the driver has stored inside its receive buffer. You never want to write code like this, use the DataReceived event instead. Apr 15, 2014 at 11:38

1 Answer 1

0

That is exactly what it does. The Dispatcher Class provides services for managing the queue of work items for a thread and the System.Action encapsulates a method that has no parameters and does not return a value.

This means that you can process the incoming data on a thread that is parallel to the thread that is receiving the data.

1
  • so any idea how should i manage the priorities and data dependencies between these threads ? Apr 15, 2014 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.