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 725523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:20:49+00:00 2026-05-14T06:20:49+00:00

I need a Timer in a ‘no form’ Delphi unit (there’s still a main

  • 0

I need a Timer in a ‘no form’ Delphi unit (there’s still a main unit with a form), so I do this:

unit ...

interface

type
  TMyTimer = Class(TTimer)
  public
    procedure OnMyTimer(Sender: TObject);
  end;

var
  MyTimer: TMyTimer;

implementation

procedure TMyTimer.OnMyTimer(Sender: TObject);
begin
  ...
end;

initialization

MyTimer := TMyTimer.Create(nil);
with MyTimer do
begin
  Interval := 1000;
  Enabled := True;
  OnTimer := OnMyTimer;
end;

finalization

FreeAndNil(MyTimer);

The problem is that the OnMyTimer procedure is never run. I’ll truly appreciate any ideas as to why 🙂

  • 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-05-14T06:20:49+00:00Added an answer on May 14, 2026 at 6:20 am

    Apart from the fact you created a MyTimer and freed a MouseTimer, I don’t see anything wrong with your code (I do assume you use your code in a GUI application or at least are having a message loop)

    This code sample works with Delphi 5. The Hello Worldget’s written to the eventlog every second.

    unit Unit2;
    
    interface
    
    uses
      extctrls;
    
    type
      TMyTimer = Class(TTimer)
      public
        procedure OnMyTimer(Sender: TObject);
      end;
    
    var
      MyTimer: TMyTimer;
    
    implementation
    
    uses
      windows, sysutils, classes;
    
    procedure TMyTimer.OnMyTimer(Sender: TObject);
    begin
      OutputDebugString(PChar('Hello World'));
    end;
    
    initialization
    
    MyTimer := TMyTimer.Create(nil);
    with MyTimer do
    begin
      Interval := 1000;
      Enabled := True;
      OnTimer := OnMyTimer;
    end;
    
    finalization
      FreeAndNil(MyTimer);
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need a timer that works like this : imagine somebody have a limit
I need a timer class which should provide functionality to start/stop/enable/disable and should be
I need an accurate timer to interface a Windows application to a piece of
I have a class that creates and uses a System.Threading.Timer, something like this: using
I am making a contest platform ..For it I need a countdown timer ..The
I need measure how time took a scriptblock (remote execution). This is my code:
I need an accurate timer, and DateTime.Now seems not accurate enough. From the descriptions
I need a regular expression that detects timer strings that could be less than
I need help with timer and List. List consist of collection of string say
I use the system.timers.timer for my service. Now I build a test-form in which

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.