在 Delphi-2010 中不推荐使用 TThread.resume 应该在什么地方使用? [英] TThread.resume is deprecated in Delphi-2010 what should be used in place?

查看:30
本文介绍了在 Delphi-2010 中不推荐使用 TThread.resume 应该在什么地方使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的多线程应用程序中

In my multithread application

我使用 TThread.suspendTThread.resume

自从将我的应用程序移至 Delphi 2010 后,我收到以下警告信息

Since moving my application to Delphi 2010 I get the following warring message

[DCC 警告] xxx.pas(277):不推荐使用 W1000 符号恢复"

如果 Resume 被弃用,应该使用什么?

If Resume is deprecated what should be used in place?

编辑 1:

我使用 Resume 命令来启动线程 - 因为它是在我终止线程之前使用CreateSuspended"设置为 True 和 Suspend 创建的.

I use the Resume command to start the thread - as it is Created with 'CreateSuspended' set to True and Suspend before I terminate the thread.

编辑 2:

这里是 delphi 2010 手册的链接

推荐答案

Charles 如果你阅读了 TThread 类的代码,你是否找到了答案.

Charles if do you read the code of TThread class , do you find the answer.

   TThread = class  
   private type  

..
..
..   
   public  
     constructor Create(CreateSuspended: Boolean);  
     destructor Destroy; override;  
     procedure AfterConstruction; override;  
     // This function is not intended to be used for thread synchronization.  
     procedure Resume; deprecated;  
     // Use Start after creating a suspended thread.  
     procedure Start;  
     // This function is not intended to be used for thread synchronization.  
     procedure Suspend; deprecated;  
     procedure Terminate;  

请参阅此链接 RAD Studio 2010:社区脉搏:后天.(第 2 部分)

如果需要同步线程,可以使用基于TMutex、TEvent和临界区的方案.

If you need to synchronize threads, you can use a scheme based on TMutex, TEvent and critical sections.

再见.

这篇关于在 Delphi-2010 中不推荐使用 TThread.resume 应该在什么地方使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆