A
A
Artem Ivantsov2014-08-18 07:28:40
Data synchronization
Artem Ivantsov, 2014-08-18 07:28:40

How to pass a message from a child thread to the main thread in C#?

I need to receive information from two boards. The boards themselves are implemented through a stump deck and there is no interrupt mode in them, therefore in two threads I will receive information from them in an endless loop and compare with the previous value. If the value changes, then the main thread will have to process this new value, and the secondary thread will continue to receive information from the board. If I make an event and generate it when it changes, then its handler will work in the same thread, which does not suit me. Only software interrupts at the kernel level come to mind, but I have no idea how this is done.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DancingOnWater, 2014-08-18
@Ramirag

There is a Dispatcher class . I think it will solve your problem

P
plasticmirror, 2014-08-18
@plasticmirror

queue to fasten. one thread removes everything from the queue and does the job, the other threads pull the boards and, if necessary, add a message to the queue.
on primitives like Monitor.Wait / Monitor.Pulse, the queue is very simple.
at the same time, the problem is solved when the values ​​change faster than the fact of changes is processed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question