Board index » delphi » How to write a constant short period delay function under Win95

How to write a constant short period delay function under Win95

Hi folks,

 I am writing a program to sample some data from I/O ports, therefore,I
 need to call a delay procedure when I am sampling the data. The
 following is the one I wrote.

 But beecaue I am running the program under win95, I find that the delay
 procedure won't delay a constant period, i.e. it will change everytimr
 when I call it. (I know that is because the Win95 is a multitasking OS)

 My problem is that is it possible to write a delay function that will
 delay a constant short period during the time I am sampling data from
 I/O port???

 Any help is appriciated!!

 Y.S. Huang  y...@pidc.gov.tw

 procedure Delay
 var
  i,x:LongInt;
  Delay_Count:LongInt;
 begin
  Delay_Count:=40;
  x:=0;
    for x:=0 to Delay_Count do
      begin
         For i:=0 to 1000 do
            asm nop; end;
      end;
 end;

 

Re:How to write a constant short period delay function under Win95


Hello,
        Try using the delay function or set a semphore for a timeout period.

Edwin

??? <y...@pidc.gov.tw> wrote in article <328BDE08.2...@pidc.gov.tw>...

Quote
> Hi folks,

>  I am writing a program to sample some data from I/O ports, therefore,I
>  need to call a delay procedure when I am sampling the data. The
>  following is the one I wrote.

>  But beecaue I am running the program under win95, I find that the delay
>  procedure won't delay a constant period, i.e. it will change everytimr
>  when I call it. (I know that is because the Win95 is a multitasking OS)

>  My problem is that is it possible to write a delay function that will
>  delay a constant short period during the time I am sampling data from
>  I/O port???

>  Any help is appriciated!!

>  Y.S. Huang  y...@pidc.gov.tw

>  procedure Delay
>  var
>   i,x:LongInt;
>   Delay_Count:LongInt;
>  begin
>   Delay_Count:=40;
>   x:=0;
>     for x:=0 to Delay_Count do
>       begin
>          For i:=0 to 1000 do
>             asm nop; end;
>       end;
>  end;

Re:How to write a constant short period delay function under Win95


Quote
On Fri, 15 Nov 1996 11:05:44 +0800, ??? <y...@pidc.gov.tw> wrote:
>Hi folks,

> I am writing a program to sample some data from I/O ports, therefore,I
> need to call a delay procedure when I am sampling the data. The
> following is the one I wrote.

> But beecaue I am running the program under win95, I find that the delay
> procedure won't delay a constant period, i.e. it will change everytimr
> when I call it. (I know that is because the Win95 is a multitasking OS)

> My problem is that is it possible to write a delay function that will
> delay a constant short period during the time I am sampling data from
> I/O port???

Use a TTimer component... Set the interval to the value you want, then
call the TTimer event when you want the delay.

Regards,

____________________
Rick Anthony
The DsGp Software Company

Re:How to write a constant short period delay function under Win95


Try this freeware component, it works for me.

http://sunsite.icm.edu.pl/~robert/delphi//ftp/free/sleeper.zip

Quote
Rick Anthony wrote:

> On Fri, 15 Nov 1996 11:05:44 +0800, ??? <y...@pidc.gov.tw> wrote:

> >Hi folks,

> > I am writing a program to sample some data from I/O ports, therefore,I
> > need to call a delay procedure when I am sampling the data. The
> > following is the one I wrote.

> > But beecaue I am running the program under win95, I find that the delay
> > procedure won't delay a constant period, i.e. it will change everytimr
> > when I call it. (I know that is because the Win95 is a multitasking OS)

> > My problem is that is it possible to write a delay function that will
> > delay a constant short period during the time I am sampling data from
> > I/O port???

> Use a TTimer component... Set the interval to the value you want, then
> call the TTimer event when you want the delay.

> Regards,

> ____________________
> Rick Anthony
> The DsGp Software Company

Re:How to write a constant short period delay function under Win95


Why not use the Sleep(x); API call? x is in milliseconds.

In article <328F8A2C.5...@pacbell.net>, bartl...@pacbell.net says...

Quote
> Try this freeware component, it works for me.

> http://sunsite.icm.edu.pl/~robert/delphi//ftp/free/sleeper.zip

> Rick Anthony wrote:

> > On Fri, 15 Nov 1996 11:05:44 +0800, ??? <y...@pidc.gov.tw> wrote:

> > >Hi folks,

> > > I am writing a program to sample some data from I/O ports, therefore,I
> > > need to call a delay procedure when I am sampling the data. The
> > > following is the one I wrote.

> > > But beecaue I am running the program under win95, I find that the delay
> > > procedure won't delay a constant period, i.e. it will change everytimr
> > > when I call it. (I know that is because the Win95 is a multitasking OS)

> > > My problem is that is it possible to write a delay function that will
> > > delay a constant short period during the time I am sampling data from
> > > I/O port???

Other Threads