zoukankan      html  css  js  c++  java
  • TTimer源码研究

    TTimerProc = procedure of object;

    IFMXTimerService = interface(IInterface)
    ['{856E938B-FF7B-4E13-85D4-3414A6A9FF2F}']
    function CreateTimer(Interval: Integer; TimerFunc: TTimerProc): TFmxHandle;
    function DestroyTimer(Timer: TFmxHandle): Boolean;
    function GetTick: Extended; // 这里不知道哪里被使用。
    end;

    TTimer = class(TFmxObject) // 注意TTimer只是包含时间器服务,并不是自己实现时间器服务
    private
    FInterval: Cardinal; // 时间间隔
    FTimerHandle: TFmxHandle; // 时间句柄,其中 TFmxHandle = THandle;
    FOnTimer: TNotifyEvent; // 时间触发事件
    FEnabled: Boolean; // 是否有效
    FPlatformTimer: IFMXTimerService; // 最重要,时间服务接口,包含3个函数
    procedure Timer; // 调用 (程序员定义的) OnTimer 事件
    protected
    // 注意,这些函数全部都是虚函数
    procedure SetEnabled(Value: Boolean); virtual; // 重要,如果与上一次的值不同,那么赋值后UpdateTimer
    procedure SetInterval(Value: Cardinal); virtual; // 重要,如果与上一次的值不同,那么赋值后UpdateTimer
    procedure SetOnTimer(Value: TNotifyEvent); virtual; // 重新指定事件后UpdateTimer
    procedure DoOnTimer; virtual; // 执行 (程序员定义的) OnTimer 事件
    procedure UpdateTimer; virtual; // 最重要,会杀掉当前时间器并重新生成(接口函数CreateTimer,根据不同平台),似乎默认开启
    procedure KillTimer; virtual; // 只要时间器句柄不等于-1就销毁,且句柄赋值为-1
    procedure Loaded; override; // 执行TComponent.Loaded(从文件内存里读出后初始化)后执行UpdateTimer
    public
    constructor Create(AOwner: TComponent); override; // 根据不同平台创建时间器,默认开启,但句柄为-1
    destructor Destroy; override; // 变量无效后 KillTimer,后者根据不同平台真正销毁(DestroyTimer接口函数)
    published
    property Enabled: Boolean read FEnabled write SetEnabled default True;
    property Interval: Cardinal read FInterval write SetInterval default 1000;
    property OnTimer: TNotifyEvent read FOnTimer write SetOnTimer;
    end;

    另外还有(帮助上竟然查不到这两个类):
    TAniThread = class(TTimer)
    TPurgatory = class (TComponent)

  • 相关阅读:
    lintcode:最大子正方形
    lintcode 中等题:k Sum ii k数和 II
    lintcode 中等题:A + B Problem A + B 问题
    Protege汉字不能正常显示问题
    Protege A DOT error has occurred错误
    lintcode :reverse integer 颠倒整数
    Reported time is too far out of sync with master. Time difference of 52692ms > max allowed of 30000ms
    Please add or free up more resources then turn off safe mode manually.
    Permission denied: user=root, access=WRITE, inode="/":hadoopuser:supergroup:drwxr-xr-x
    Hadoop重新格式化HDFS的方法
  • 原文地址:https://www.cnblogs.com/findumars/p/3672306.html
Copyright © 2011-2022 走看看