Firemonkey iPad等待图标 [英] Firemonkey iPad waiting icon

查看:101
本文介绍了Firemonkey iPad等待图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序上有两个选项卡.他们两个都有一张表-一个用于输入,一个用于输出.激活输出表的选项卡后,将触发一个过程,该过程分析数据并填充输出网格.

I've got two tabs on my application. Both of them have a table - one for input and one for output. When the tab for the output table is activated, a process is triggered which analyze the data and populated the output grid.

输出网格需要几秒钟的渲染时间,我想显示一些动画图标.我已经尝试过将TImage与TFloat动画以及TAniIndicator一起使用.在分析过程运行时,它们似乎都冻结了.

The output grid takes a few seconds to render and I would like to display some animated icon. I have tried a TImage with a TFloat animation as well as the TAniIndicator. Both of them seems to freeze while the analyze process is running.

推荐答案

听起来像是单线程应用程序.问题是一个线程一次只能执行一个任务".

Sounds like you have single-threaded application. The problem is that one thread can do one "task" at a time.

对于单线程应用程序,主线程负责执行以下操作:

In the case of single-threaded applications the main thread is responsible for a couple of things:

  • 处理UI内容(刷新,绘制等)
  • 执行代码,即对TabTActivate()之类的控件事件做出反应

因此,当您执行Analyze()函数时,主线程被阻塞,因此无法刷新UI.副作用是动画似乎停滞了.

So when you execute your Analyze() function the main thread is blocked and thus cannot refresh UI. As a side effect Animations seem to freeze.

我建议在单独的线程中移动长期运行的任务.任务完成后,发出信号通知主线程停止指示器并继续接收用户输入.这样,主IU线程将不会被阻塞并且TAniIndicator将正常运行.

I would suggest moving long-running tasks in separate threads. After the task has finished signal the main thread to stop the indicator and continue to receive user input. This way the main IU thread will not be blocked and TAniIndicator will function correctly.

NB:当心线程同步和线程安全! VCL/FMX组件不是线程安全的. 您可以在此处找到有用的信息:

NB: Beware of thread synchronization and thread safety! VCL/FMX components ARE NOT thread-safe. You can find useful information here:

  • Synchronizing Threads and GUI in Delphi application
  • Under The Hood #4 - Is the VCL thread-safe?
  • INDY 10 TCP Server - Combine with non thread safe VCL Code
  • Multithreading - The Delphi Way

这篇关于Firemonkey iPad等待图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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