Main Content

getCurrentTask

Get task object from a worker running a task

    Description

    example

    t = getCurrentTask returns the parallel.Task object that the current worker is associated with. Use getCurrentTask to get information from the task during a computation, such as the running duration.

    If getCurrentTask is evaluated on a worker, t is a parallel.Task object. Otherwise, t is an empty double.

    Examples

    collapse all

    Use getCurrentTask and RunningDuration property to find the running duration of the task that a worker is associated with.

    On a worker, use getCurrentTask to get the current task object t from a worker running the task t.

    t = getCurrentTask;

    Then, use the RunningDuration property to get the running duration of the task.

    howLong = t.RunningDuration

    Output Arguments

    collapse all

    Task object, specified as a parallel.Task or empty double. When you use getCurrentTask on a worker, t is the parallel.Task object that the current worker is associated with. When you use getCurrentTask on the client, t is an empty double.

    Data Types: parallel.Task

    Version History

    Introduced before R2006a