Skip to Main Content Skip to Search
Product Documentation

FinishedFcn - Specify callback to execute after task or job runs

Description

FinishedFcn specifies the function file 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

Function handle

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

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS