For a start, I think you will want to call the sleep function in the Execute
loop otherwise the CPU will go to 100%, and having a tpHigher priority, this
will likely semi-hang your main program thread.

Ross.

-----Original Message-----
From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On Behalf
Of John Dammeyer
Sent: Wednesday, 6 May 2009 7:56 a.m.
To: 'Borland's Delphi Discussion List'
Subject: Idle thread

Hi,

I've created a unit that has a thread that has a TTimer object that runs
periodically to access an A/D converter.

      AtoDThread := TAcquisitionThread.Create(FALSE);
        AtoDThread.Priority := tpHigher;
        AtoDThread.Resume; // now run the thread

Inside the AtoDThread the Execute

    DLPortIO :=  TDLPortIO.Create(nil);
    DLPortIO.DriverPath := 'c:\DMT\Plotter'; // This is where we've
installed it.

    AtoDState := RESET_HARDWARE_STATE;
    while not Terminated do
        ;       // Do nothing but ideally suspend somehow while leaving
the timer running.

What I'd like to do is just have the Execute thread do nothing else other
than let the timer fire which then gathers the data and fills appropriate
variables etc.

If I suspend the thread I believe it will also suspend the timer won't it?
What's a better way to block the execute part of the thread while leaving
the timer active?

Thanks
John

_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to