Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:42+00:00 2026-06-16T00:34:42+00:00

Dear Delphi programmers, I’m looking for help how to write a one-shot timer (No

  • 0

Dear Delphi programmers,

I’m looking for help how to write a one-shot timer (No GUI, so VCL Timers out of question)…

Let me explain a little bit more.

In my code (explaining with VCL timer but in this particular project I have no forms):

  1. Call a procedure which send a char over serial port
  2. Enable a timer with a X amount of Interval

In the OnTimer event:

I have a code which send a char then disable the timer itself to never be executed again.

The problem is that I need to make the creation of these timers dynamic.
I thought of the function SetTimer() then KillTimer() in the “OnTimer event” to disable it (free it).

Is it a good (safe) way?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:34:43+00:00Added an answer on June 16, 2026 at 12:34 am

    Is it safe to kill timer from inside of a timer event ?

    Yes, that’s perfectly safe.

    How to implement simplest one shot timer ?

    The easiest implementation of a 1 second one shot timer is this, but note, that if you start more of them, you won’t be able to distinguish which one of them elapsed its interval:

    procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR;
      dwTime: DWORD); stdcall;
    begin
      KillTimer(0, idEvent);
      ShowMessage('I''m done!');
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      SetTimer(0, 0, 1000, @TimerProc);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear Programmers, I need to compare one column value to another column in single
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear all,Now i have this question in my java program,I think it should be
Dear All, please help me since I'm newbie in SQL Server. I have a
Dear friends, I need your help. I need to send .bmp file to another
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
dear all.. i'm new to ajax timer, since someone tell me to use it
Dear CUDA users I am reposting a question from nvidia boards: I am currently
Dear LINQ or linq2sql experts, can you help me to solve this case? I
Dear Friends good afternoon. My problem may be this is very basic one i.e.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.