I didn't need any documentation to work out what was going on...
Start with a blank PHP file:
PHP:
<?php
class YourAddOn_Deferred_SomeAction extends XenForo_Deferred_Abstract
{
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
// The code you want to execute here.
return false;
}
}
Normally there'd be a bit more logic before returning false. The reason for that is, Deferred classes usually run for longer periods of time that the 900ms you mention and they're usually working with much larger amounts of data.
You normally work with the data in batches and if you still have data to process you return $data at the end, which will signal the Deferred system to enter another Deferred entry and work with the next batch of data and so on.
The "bit more logic" I mentioned would usually check if there's any more data to work with. If there is, return $data. If there isn't, return false.
So, in your case, just returning false at the end is absolutely fine.
More on the actual deferred class in a minute. To execute your Deferred action:
PHP:
XenForo_Application::defer('YourAddOn_Deferred_SomeAction', $data);
$data should simply contain an array of data you need to work with.
Back to your Deferred class:
PHP:
<?php
class YourAddOn_Deferred_SomeAction extends XenForo_Deferred_Abstract
{
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
// The code you want to execute here.
return false;
}
}
The data you passed in is available in $data. You now just need to write your function that does things with that data. It will run entirely in the background and should be invisible to the end user.