delphi – 在等待DataSnap时更新客户端UI

delphi – 在等待DataSnap时更新客户端UI,第1张

概述我在Delphi XE2中创建了一个MDI Delphi应用程序,它通过TSQLConnection组件(driver = datasnap)连接到DataSnap服务器.在设计时右键单击TSQLConnection可以生成DataSnap客户端类(ProxyMethods). 我的目标是在客户端有一个经过时间的时钟[0:00],显示DataSnap请求服务的时间,每1秒更新一次.我尝试过但不起作 我在Delphi XE2中创建了一个MDI Delphi应用程序,它通过TsqlConnection组件(driver = datasnap)连接到DataSnap服务器.在设计时右键单击TsqlConnection可以生成DataSnap客户端类(ProxyMethods).

我的目标是在客户端有一个经过时间的时钟[0:00],显示DataSnap请求服务的时间,每1秒更新一次.我尝试过但不起作用的两种方法是:

方法#1

Use a TTimer with a 1 second interval that updates the elapsed time clock while a ProxyMethod is being execute. I enable the timer just before calling the ProxyMethod. While the ProxyMethod is running,the OnTimer event doesn’t fire — a breakpoint in the code is never hit.

方法#2

Same as Method #1,except the timer is a TJvThreadTimer. While the ProxyMethod is running,the OnTimer event fires,but the OnTimer code doesn’t get execute until after the ProxyMethod completes. This is evIDent because a breakpoint in the OnEvent code gets hit in rAPId succession after the ProxyMethod completes — like the OnTimer events have all been queued in the main VCL thread.

此外,在慢速ProxyMethod运行时单击客户端应用程序上的任何位置会使应用程序显示为挂起(标题栏中显示“Not Responding”).

我认为最好的解决方案是将ProxyMethods的执行移动到一个单独的线程.但是,必须有一个现有的解决方案 – 因为相关的挂起应用程序问题似乎是一个常见的抱怨.我只是找不到解决方案.

任何建议表示赞赏.否则,我将辞职,将ProxyMethod执行移动到一个单独的线程中.

解决方法 您已经确定了根本问题.您的查询正在UI线程中运行,并在运行时阻止该线程.不会发生UI更新,计时器消息无法触发等.

I think the best solution is to move the execution of the ProxyMethods to a separate thread. However,there must be an existing solution — because the related hung app issue seems like it would be a common complaint. I just can’t find the solution.

您已经找到了解决问题的唯一方法.您必须在UI线程以外的线程中运行长时间运行的查询.

总结

以上是内存溢出为你收集整理的delphi – 在等待DataSnap时更新客户端UI全部内容,希望文章能够帮你解决delphi – 在等待DataSnap时更新客户端UI所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1268178.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-08
下一篇2022-06-08

发表评论

登录后才能评论

评论列表(0条)

    保存