🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.misc
2 messages
2 total messages Started by Ian Boag Tue, 07 Nov 2000 00:00
WaitFor, TEvents and all that
#317
Author: Ian Boag
Date: Tue, 07 Nov 2000 00:00
28 lines
1699 bytes
I am trying to get to grips with using WaitFor and TEvents. So I have put
together a very simple program that encapsulates my problem. It has two
buttons an a list box. Whan I click Button1, it sets off a process that
waits for Button2 to be clicked. The a message is put up  ...

First I make a TEvent (MyEvent) and Create it.

Form1.Create is
MyEvent.Create(nil,false,false,'');

Button1Click is then
  MyEvent.ResetEvent   (turns it "off")
  MyEvent.WaitFor(20000); (wait 20 seconds)
  write some sort of message

Button2Click is just
  MyEvent.Set

When I do all this I get an exception error to do with accesses and stuff
that I don't understand any of. Anyone able to help?

The reason I want to do this is actually much more complicated that two
buttons, but if I can make this one work I'll be able to do the auto FTP
client that I an REALLY trying to build ....

       Cheers

          Ian Boag
Re: WaitFor, TEvents and all that
#316
Author: Olaf Kaul
Date: Tue, 07 Nov 2000 00:00
37 lines
1382 bytes
On Tue, 7 Nov 2000 21:26:23 +1300, "Ian Boag"
<ianboag@partslink.co.nz> wrote:


>First I make a TEvent (MyEvent) and Create it.
>
>Form1.Create is
>MyEvent.Create(nil,false,false,'');
>
>Button1Click is then
>  MyEvent.ResetEvent   (turns it "off")
You did reset the event, before you started to wait for it.
For the Method "waitfor" the event will never be signaled.


>  MyEvent.WaitFor(20000); (wait 20 seconds)
>  write some sort of message
>
>Button2Click is just
>  MyEvent.Set
>


try this in Button 1 Click:

case MyEvent.WaitFor(20000) of
    wrSignaled:  
       Begin    
         MyEvent.ResetEvent;Edit1.text:='Signaled';
       End;
  
     wrTimeout:Edit1.Text:='timeout';
  end;



Olaf
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads