Root > Reference > All Classes > TThreadEx > Methods > TThreadEx.Create

Constructor TThreadEx.Create

Previous pageReturn to chapter overviewNext page   

Creates an instance of a thread object.

 

Unit

EBase

 

Syntax

 

Code (Delphi)

public

constructor Create;

overload;

 

constructor Create(

CreateSuspended: Boolean

); overload;

 

constructor Create(

const AName: String;

const AELEnabled: Boolean = True

); overload;

 

constructor Create(

CreateSuspended: Boolean;

const AName: String;

const AELEnabled: Boolean = True

); overload;

 

Parameters

CreateSuspended [in, opt]

If CreateSuspended is False, Execute is called immediately after the constructor. If CreateSuspended is True, Execute is not called until after the Start method is called.Default is False.

 

AName [in, opt]

Defines thread's name. Thread name is arbitrary text string which can contain any combination of characters. Thread name will be visible in IDE's debugger. It also will be used by EurekaLog in bug reports. Default is empty name (no name; TID will be used to identify this thread).

 

AELEnabled [in, opt]

Defines EurekaLog status in created thread. Default is True. This argument is ignored if you compile your application without EurekaLog.

 

Remarks

Call Create to create a thread in an application.

 

Examples

 

Code (Delphi)

// Execute thread immediately:

Thread := TMyThread.Create;

 

Code (Delphi)

// Create thread suspended:

Thread := TMyThread.Create(True);

 

// ...

 

// Start thread's execution

Thread.Start;

 

Code (Delphi)

// Name and execute thread immediately:

Thread := TMyThread.Create('My background thread');

 

Code (Delphi)

// Create named thread suspended:

Thread := TMyThread.Create(True, 'My background thread');

 

// ...

 

// Start thread's execution

Thread.Start;

 

Threads launched with TThreadEx class will be EurekaLog-enabled by default. You can supply optional Boolean argument for TThreadEx's constructor to disable EurekaLog in thread, for example:

 

Code (Delphi)

Thread := TMyThread.Create('Thread Name', False { disable EurekaLog in thread } );

 

Of course, you can use the same approach while supplying Suspended argument, for example:

 

Code (Delphi)

Thread := TMyThread.Create(

False { create thread running },

'Thread Name',

False { disable EurekaLog in thread } );

 

Thread := TMyThread.Create(

True { create thread suspended},

'Thread Name',

True { enable EurekaLog in thread } );

 

See also

SetEurekaLogStateInThread Function
NameThread Function



Send feedback... Build date: 2018-11-26
Last edited: 2018-11-26
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_method_ebase_tthreadex_create.php