#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2015
    Posts
    1
    Rep Power
    0

    Programming cyclic event


    Hello everyone.
    My question is not really programming language related, but more general so I thought I'll post it here.
    I'm programming in windows environment (Delphi).
    I'm working on a small app that supposed to communicate with another device.
    Communication can be established on ethernet or serial link and poll device in set periods of time - say 1 s (can be changed).

    I did some reading and found couple ways to do this.
    One is timers queues. Once it created it fires event at defined time interval and since callback function is processed
    in different thread it didn't freezes app.
    Another way is to create thread and process polling in that thread, but to make it work in defined interval i would need to pause thread.
    I read somewhere that pausing thread is a bad practice.

    What are the other ways to achieve this? What is a good practice to do this?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2014
    Posts
    6
    Rep Power
    0
    It's not that hard.
    Drop a TTimer on the form from the System Tab.
    Set up the Interval in the Object Inspector. (Default is 1000 mS)
    Select the OnTimer Event
    Change to the Code view.

    [FONT=Courier New]procedure TTabbedForm.Timer1Timer(Sender: TObject);
    begin

    end;
    [/
    FONT]

    Put the code you want to run there. You can disable/enable it with Timer1.Enabled := FALSE;
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2014
    Posts
    44
    Rep Power
    4
    Newer versions (notably XE) are far more better than 2006, that was pretty buggy version. And Delphi usage is definitly declining and IMO only reason is price. Delphi is very expensive and there is no free version. Even compiler is not free and that practicaly eliminates Delphi as tool for open source development.

    And one thing that contributed far more to that slow declining is Delphi .NET compiler, Borland and later CodeGear put much effort in that product but that was big big mistake.

IMN logo majestic logo threadwatch logo seochat tools logo