只能说碰碰运气了。环境:EHLIB5.0 /  DELPHI2007 虽然大多人都用DBGRIDEH,但刚好遇到我这个问题的应该不多。 
SaveDBGridEhToExportFile(TDBGridEhExportAsRTF,frmdm2.DBGridEh1,FileName,true) 就这一句,如果放入线程中执行,死锁。 但如果将TDBGridEhExportAsRTF改成, AsText 或者 asCSV 都没问题。 因为量大,所以只能放入线程中执行,而且我又要的是rtf,因为我要生成的文件保留我DBGRideh中的背景。 不知是否有高手可以解决这个问题!

解决方案 »

  1.   

    多线程,我将一些代码(解决将数据库导出到rtf文件)放入一个多线程中执行,就死机。后来一个个查,发现就是那句引起的,奇怪的是,只是不能够使用rtf格式,txt,csv就可以
      

  2.   

    最新进展:把这个过程不放在 多线程中,而放入一个 timer中,执行正常。如果硬是没有好的办法,就只是把它放到这个timer中,需要的时候就把timer设为on,用了就关。
      

  3.   

    没用过,帮你顶
    或者你可以在用过后调用一下Application.ProcessMessages试试
      

  4.   

    DBGridEh1 多线程不安全,它的更新,不要在线程里操作,放到同步里看看吧
      

  5.   

    我也遇到过放在timer中可以用,但在线程中不能用的情况,,一般线程中使用同步函数就解决了
    procedure Synchronize(Method: TThreadMethod);ParametersMethod: TThreadMethodTThreadMethod VCL method to be executed.
    DescriptionSynchronize is used to avoid multi-threading conflicts that can arise from accessing object properties or methods that are not thread-safe, or using resources not in the main thread of execution.
    Execution of the thread is suspended while Synchronize completes the call to Method.
    Note: Methods can also be protected using critical sections or the multi-read exclusive-write synchronizer.
    Note: Synchronize is redeclared as a public method in TIdThread.