System.Threading.TTask.Run
Delphi
class function Run(Sender: TObject; Event: TNotifyEvent): ITask; overload; static; inline;
class function Run(Sender: TObject; Event: TNotifyEvent; APool: TThreadPool): ITask; overload; static; inline;
class function Run(const Func: TProc): ITask; overload; static; inline;
class function Run(const Func: TProc; APool: TThreadPool): ITask; overload; static; inline;
C++
static _di_ITask __fastcall Run(System::TObject* Sender, System::Classes::TNotifyEvent Event)/* overload */;
static _di_ITask __fastcall Run(System::TObject* Sender, System::Classes::TNotifyEvent Event, TThreadPool* APool)/* overload */;
static _di_ITask __fastcall Run(const System::Sysutils::_di_TProc Func)/* overload */;
static _di_ITask __fastcall Run(const System::Sysutils::_di_TProc Func, TThreadPool* APool)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Threading.pas System.Threading.hpp |
System.Threading | TTask |
Description
Run starts running a task and returns an instance of ITask.
Call the first overloaded Run method with the parameters described below:
Parameter | Meaning |
Sender
|
An object containing data to be used by the method. |
Event
|
The worker event that is started. |
Call the second overloaded Run method with the parameters described below:
Parameter | Meaning |
Sender
|
An object containing data to be used by the method. |
Event
|
The worker event that is started. |
APool
|
A thread-pool thread is associated to execute the event. |
Call the third overloaded Run method with the parameters described below:
Parameter | Meaning |
Func
|
A TFunc reference to the task executed. |
Call the fourth overloaded Run method with the parameters described below:
Parameter | Meaning |
Func
|
A TFunc reference to the task executed. |
APool
|
A thread-pool thread is associated to execute the task. |
The functions passed to TTask.Run is targeted to run in parallel threads depending on available CPU and threading resources. The method overloads involving a Sender parameter pass the Sender object to the targeted function as a parameter when executed. Method overloads with a TThreadPool parameter draw their threading resources from it rather than the default pool, which is useful when the consumption of threading resources should be limited.