zoukankan      html  css  js  c++  java
  • Indy FTP 警告:Only one TIdAntiFreeze can be active in an application

    > Should I use a AntiFreeze component on every form I have a TIdTCPClient 
    > component?  Or is one enough to handle the whole Application? 

    One is enough. According to the Indy help file, 

    -------- 
    Only one TIdAntiFreeze can be active in an application. If another 
    instance already exists, an exception is raised. 
    -------- 

    Note that if you have multiple TIdTCPClient objects connected at the 
    same time, and you call ReadXXX twice or more often (e. g. on a button 
    click event) in the main thread context, then the last called ReadXXX 
    will return first, blocking the other ReadXXX requests even if they 
    could return data. This is because of the nature of the AntiFreeze 
    mechanism. 

    To avoid this effect, use a dedicated reader thread for each connection 
    instead of AntiFreeze. There is a TIdTCPClient descendant with its own 
    reader thread, firing an event when data arrive, at 
    http://come.to/delphi-bits . 

    -Michael 

    TIdAntiFreeze
    Prevents an application UI from freezing.
    TIdAntiFreeze = class(TIdAntiFreezeBase)
    Unit
    Description
    Indy works on the blocking model. That is when calls are made to Indy the do not return until they are complete. If calls are made in the main thread this will cause the Application User Interface to "freeze" during Indy calls. TIdAntiFreeze counter acts this effect. TIdAntiFreeze allows Indy subsystem to make process Application message calls so that Windows messages continue to be executed while Indy blocking socket calls are in effect.

    Only one TIdAntiFreeze can be active in an application. If another instance already exists, an exception is raised. TIdAntiFreezeBase uses the global variable GAntiFreeze, declared in the TIdAntiFreezeBase unit, to determine if another instance has already been created.

    Note: GAntiFreeze is not assigned if an instance is added in the form designer (during design time).

    Note: The TIdAntiFreeze.pas unit must NOT appear in the uses clause of any Indy or descendant unit. This unit is linked in an application when the component is placed on a Form. This is done to preserve isolation from the Forms.pas and QForms.pas units.


    TIdAntiFreeze.Process
    Implements TIdAntifreeze functionality.
    procedure Process; override;
    Description
    Process is the overridden implementation of the abstract virtual TIdAntiFreezeBase.Process method. Process inspects the ApplicationHasPriority property to determine if Application.ProcessMessages is called. If False, the pending Windows message is dispatched to Application.HandleMessage.

    Note: Due to the differences in message dispatching, Process does not use or inspect ApplicationHasPriority on the Linux Platform; Process simply calls Application.ProcessMessages.

    Note: The TIdAntiFreeze.pas unit must NOT appear in the uses clause of any Indy or descendant unit. This unit is linked in an application when the component is placed on a Form. This is done to preserve isolation from the FORMS.PAS and QForms.pas units.

     

     

     

  • 相关阅读:
    OpenStack 发行版本
    刷新linux硬盘存储接口
    LVM实践
    LVM man帮助
    ansible --help 文档
    nmcli connection modify eth1 ipv4.addr "192.168.31.23" ipv4.method manual
    自己动手使用, MetaWeblog 发布博客(cnblogs)
    测试图片上传 on Markdown editor
    大批量更新数据mysql批量更新的四种方法
    PHP print_r 转换/还原为数组
  • 原文地址:https://www.cnblogs.com/kayvanguo/p/5693834.html
Copyright © 2011-2022 走看看