Run asynchronous tasks in Drupal easily.
Install as normal Drupal module and activate.
Register asynchronous task for a heavy function.
// Execute the heavy task asynchronously.
asynk( 'sample_heavy_task', $key, $lan );
Heavy resource task for execution
// Send email to 10 people.
function sample_heavy_task( $key, $lan ) {
for ( $i = 0; $i < 10; $i ++ ) {
drupal_mail( 'my_module', $key, 'sample@sample.com', $lan );
}
}
You can not pass object as a parameter. It will be converted to array automatically through $_POST
.