unit IRQThreadUnit; interface uses Classes, Windows, Sample4u; type IRQThread = class(TThread) private LastError: LongWord; procedure ReportError; protected procedure Execute; override; end; implementation uses SysUtils, AIOWDM; procedure IRQThread.Execute; begin while not Terminated do begin if Sample4Form.GoFlag then begin //NOTE: Synchronize is not needed unless you WaitForIRQ(Sample4Form.CardNum); //call VCL functions in ISR. It is provided for Synchronize(Sample4Form.ISR); //your convenience. end; // end if end; // end while LastError := GetLastError(); Synchronize(ReportError); end; // end Execute procedure IRQThread.ReportError; begin Sample4Form.HandleError(LastError); end; // end ReportError end.