Which is the correct way to start a suspended thread in delphi 2007?

后端 未结 5 1908
南笙
南笙 2020-12-17 22:01

In delphi XE I can use the start procedure, but this method does not exist in delphi 2007.

This sample code works ok in delphi xe, using Start

MyThread         


        
5条回答
  •  一个人的身影
    2020-12-17 22:34

    Resume and Suspend are deprecated in Delphi 2010 and newer versions. Seems it is basically to discourage using them for thread synchronization. They are not meant for that.

    Anyways, if all you want to do is resuming a thread created suspended, then calling Resume in older versions is safe.

    If you need to use the same source code in both Delphi 2007 and Delphi XE, then you can use conditional compiling to avoid warning in XE.

    Also, take a look at this question which is related to your question:

    TThread.resume is deprecated in Delphi-2010 what should be used in place?

提交回复
热议问题