Products & Services Solutions Academia Support User Community Company

Learn more about Parallel Computing Toolbox   

FinishedFcn - Specify callback to execute after task or job runs

Description

FinishedFcn specifies the M-file function to execute when a job or task completes its execution.

The callback executes in the local MATLAB session, that is, the session that sets the property, the MATLAB client.

Characteristics

Usage

Task object or job object

Read-only

Never

Data type

Callback

Values

FinishedFcn can be set to any valid MATLAB callback value.

The callback follows the same model as callbacks for Handle Graphics®, passing to the callback function the object (job or task) that makes the call and an empty argument of event data.

Examples

Create a job and set its FinishedFcn property using a function handle to an anonymous function that sends information to the display.

jm = findResource('scheduler','type','jobmanager', ...
          'name','MyJobManager','LookupURL','JobMgrHost');
j = createJob(jm, 'Name', 'Job_52a');

set(j, 'FinishedFcn', ...
    @(job,eventdata) disp([job.Name ' ' job.State]));

Create a task whose FinishFcn is a function handle to a separate function.

createTask(j, @rand, 1, {2,4}, ...
    'FinishedFcn', @clientTaskCompleted);

Create the function clientTaskCompleted.m on the path of the MATLAB client.

function clientTaskCompleted(task,eventdata)
   disp(['Finished task: ' num2str(task.ID)])

Run the job and note the output messages from the job and task FinishedFcn callbacks.

submit(j)
Finished task: 1
Job_52a finished

See Also

Properties

QueuedFcn, RunningFcn

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS