目的:client不断读取server数据,避免GUI死机状态,希望用antifreeze实现.
看到demo中的例子只是定义了antifreeze的实例,不需要在代码实现中操作吗?我也按照例子,只是定义,没起作用.
 我是个新手,请说一下具体实现(加200分),有能实现代码更好了(再加500分)
 没办法,就是容易还分多!

解决方案 »

  1.   

    antifreeze的确是不需要代码的,Indy内部就提供antifreeze的支持
    用antifreeze也没有代码可写的Indy的文档:TIdAntiFreeze
    Indy has a special component that solves the user interface freeze problem transparently. The
    existence of a single TIdAntiFreeze instance in an application, allows the use of blocking calls in the
    Introduction to Clients 40
    (C) 2003 Atozed Computer Software Ltd.
    This book is registered to Jan West
    main thread without the User Interface being frozen.
    The TIdAntiFreeze works by internally timing out calls to the stack and allowing messages to be
    processed during the timeout periods. The external calls to Indy continue to block, and thus code
    works exactly as without a TIdAntiFreeze.
    Since the user interface freeze is only affected by blocking calls in the main thread, TIdAntiFreeze
    only affects Indy calls made from the main thread. If an application uses Indy in threads,
    TIdAntiFreeze is not required. If used, it will only affect calls made from the main thread.
    Use of a TIdAntiFreeze will slow the socket communications somewhat. How much priority should be
    given to the application versus the socket communication is configurable with the properties of
    TIdAntiFreeze. The reason that usage of a TIdAntiFreeze slows the socket communication is that the
    main thread is allowed to process messages. Because of this care must be taken to not allow too
    much time to be consumed in events caused by messages. These include most user interface events
    such as OnClick, OnPaint, OnResize and many others. Since non-blocking sockets rely on messages
    themselves, the described problem always applies to non-blocking sockets. With Indy and the
    optional use of a TIdAntiFreeze, the programmer has complete control.
      

  2.   

    已经实现了,的确是只要定义就好,还有antifreeze1.active=true.
    报告一下原来不能实现的原因,timer一直是true,在timer控件中使用了readbuffer,一个readbuffer被卡住后,导致同一时间有并行的多个readbuffer方法存在,用了antifreeze也没用。解决方法,设timer = false ,connect成功后开始timer ,而进入timer 后首先timer =false,离开timer 时,timer =true,即保证timer中的功能(readbuffer)线性实现。ly_liuyang(Liu Yang)也多谢了,你的文档是哪里的?我只有indy in depth,感觉内容很好,但是少了些。
    分数没问题,我只能一次给100分,再开2个帖子,给你追一共200分。(幸亏没代码,省了500分:>)
    开始感觉indy 是个好老师,看它,对于网络编成有很大的帮助,希望和大家一起交流!
    mail:[email protected]