Raising an event at t0+dt

  • Thread starter Thread starter Oriane
  • Start date Start date
Yes that was my first intention. But this is considered as not optimal by
Jon...and I agree with him !

Well, I was considering the situation when I just thought the problem
was "keep processing until a particular time". If it makes the code
simpler to wait until a particular time and then process everything
you've received so far, then a timer could well be a good way of
proceeding.

Jon
 
Correction:
Oriane said:
"Peter Duniho" <[email protected]> a écrit dans le message de

Yes. The data will be changed by 2 threads (running WCF + an USB driver),
ans will be enqueud in a class/global variable. Jon thinks that I should
using a Monitor (Pulse/Wait).
The data (that is the position of the tags) will be received by two
different threads (anyway I need one for the WCF channel) and will be
enqueued in a class/global variable. The "main thread" will then dequeued
them and make computation.
 
The data (that is the position of the tags) will be received by two
different threads (anyway I need one for the WCF channel) and will be
enqueued in a class/global variable. The "main thread" will then
dequeued them and make computation.

Then it seems to me that a Forms.Timer is exactly what you need. Just
don't forget to lock the data queue when the main form thread is dequeuing
the data, and when the receiving threads are enqueing the data. However,
since you should already be doing that now, I'm guessing that's not an
issue for you.

Though, that said there is one caveat: due to the way that Windows works,
none of the timers are particularly accurate, and the Forms.Timer is the
least accurate. It has a resolution of (according to the documentation)
only 55 milliseconds. In some applications, this would be unacceptable.
It sounds to me as though you're dealing with much larger time values than
that, and an error of 55 milliseconds isn't a problem. But if it is,
you'll have to use a different Timer class (there are two others).

Pete
 
Back
Top