zoukankan      html  css  js  c++  java
  • kbmMW 5.13.00 Scheduler不执行SynchronizedAfterRun

    kbmMW 5.13.00发布了,升级后遇到这个问题,SynchronizedAfterRun不执行。

    procedure TForm4.Button1Click(Sender: TObject);
    begin
       Text1.Text:='线程在运行中';
       Scheduler.Run(procedure
                     var
                        i:Integer;
                     begin
                       for I := 1 to 10 do
                          sleep(100);
                     end)
                 .SynchronizedAfterRun(procedure
                                       begin
                                          Text1.Text:='线程执行完成,执行SynchronizedAfterRun方法。'
                                       end)
                 .Activate(True);
    end;

    这段代码,做为测试项目运行,没有问题,但类似的写法在我实际生产的项目中,则大多数情况下不执行SynchronizeAfterRun方法。本想给作者写个demo项目重显问题,无耐又无法重显!

    给作者反应,下面是他的回复:

    在BBS上回复:

    (replied directly by email)
    SynchronizedAfterRun now use Queue rather than Synchronize, to be sure it will not deadlock in some situations, where the main thread is blocked.
    To ensure the after run is executed, the mainthread must allow for execution from time to time.

    (直接通过电子邮件回复)
    现在,SynchronizedAfterRun使用Queue而不是Synchronize,以确保在某些情况下(主线程被阻塞)它不会死锁。
    为了确保执行后运行,主线程必须不时允许执行。

    邮件回复:

    It queues the sync request to run, which means that you must give your 
    GUI a chance to update for the code in the SynchronizedAfterRun to be 
    allowed to run.

    它对要运行的同步请求进行排队,这意味着您必须给GUI一个机会来更新要允许运行SynchronizedAfterRun中的代码。

    看了回复,不知道如何写代码。

    对比分析一下5.13与版本5.12的区别:

    试着将Queue替换为Synchronize,运行,应用正常了!

    Delphi 10.3.3 win32

    又试着解决这个问题,终无果!只好改成Synchronize。

  • 相关阅读:
    Linux的僵尸进程及其解决方法
    描述linux系统从开机到登陆界面的启动过程
    __weak、__strong这样的关键词和weak、strong有哪些区别
    选择器(UIPickerView)
    UITableView 滚动流程性优化
    几种设置UITableView的cell动态高度的方法
    强大的Core Image(教你做自己的美图秀秀))
    iOS UIBezierPath类 介绍
    Quartz 2D编程指南- PDF文档的创建、显示及转换
    Quartz 2D编程指南(4) - 颜色和颜色空间
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/13976718.html
Copyright © 2011-2022 走看看