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.

     

     

     

  • 相关阅读:
    css水平垂直居中
    JavaScript提供了哪几种“异步模式”?
    sort()
    后端开发中,可以在Cache-Control设置的常用指令
    纯函数
    react和vue
    npm(classnames) 更灵活使用类名
    shell知多少?
    常见的HTTP状态码
    axios
  • 原文地址:https://www.cnblogs.com/kayvanguo/p/5693834.html
Copyright © 2011-2022 走看看