"Zeev Jabotinsky" <ta...@netvision.net.il> wrote in message
news:079a01c38df7$62dc9e50$a101...@phx.gbl...
Zeev
>.
>
To the suggestion to have a separate thread you
wrote "That does not work better than timers that
trigger events.". Did you really try that? If
so, how? I would try something like this:
ThreadProc()
{
Thread.CurrentThread.Priority = Thread.ThreadPriority.AboveNormal;
while (...)
{
DoMyWork();
Thread.Sleep(50); // or maybe even 0 here
}
}
Having a thread sleeping and then doing work is
not the same thing as using timer threads from
the thread pool. I would expect a better result
with a separate thread.
"Zeev Jabotinsky" <anon...@discussions.microsoft.com> wrote
If you really need highly accurate, short period timers, it would be best to
look at windows Multimedia timers, but you'd have to write some unmanaged
code to access it.
Sean
"Steve" <nos...@nospam.com> wrote in message
news:Ouw4Trdl...@TK2MSFTNGP10.phx.gbl...
The other way would be to take the datetime when you wake up (using one
thread) and before sleeping, subtract to get a timespan and sleep the
remaining time. If the timespan is less than 0, then you've overworked, and
no sleep happens.
Setting the thread priority to realtime could help as well to ensure you get
scheduled.
-mike
MVP
"Sean Wolfe" <swolfe.N.0.$.p.A.^^@spindlex.N.0.$.p.A.^^.com> wrote in
message news:%23alIQd6...@TK2MSFTNGP10.phx.gbl...