每x秒执行一次动作delphi [英] Execute action every x seconds delphi

查看:71
本文介绍了每x秒执行一次动作delphi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图每x秒执行一个函数(或过程)。

I'm trying to execute a function(or procedure) every x seconds.

我一直到处寻找,但似乎从未找到适合我需要的东西

I've been looking everywhere but never seemed to find something that suits my needs.

我的应用程序基本上是从Web上获取数据的,所以我想创建一个自动刷新复选框。
因此,假设用户选中了该框,我希望应用程序每5秒调用一次该函数。

My application basically gets data from the web and I want to make an auto-refresh checkbox. So let's say the user checks the box, I want the app to call that function every 5 seconds.

谢谢!

推荐答案

使用 TTimer (来自 System 标签)。将时间间隔设置为秒数* 1000(从毫秒转换为秒),并为 OnTimer 事件编写一个处理程序。

Use a TTimer (from the System tab in the component palette). Set the interval to the number of seconds * 1000 (converting from milliseconds to seconds), and write a handler for the OnTimer event.

这篇关于每x秒执行一次动作delphi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆