
我的目标是在客户端有一个经过时间的时钟[0:00],显示DataSnap请求服务的时间,每1秒更新一次.我尝试过但不起作用的两种方法是:
方法#1
Use a
TTimerwith 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,theOnTimerevent 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,theOnTimerevent fires,but theOnTimercode doesn’t get execute until after the ProxyMethod completes. This is evIDent because a breakpoint in theOnEventcode gets hit in rAPId succession after the ProxyMethod completes — like theOnTimerevents 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所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)