You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Spatie\Async\Task;
class MyTask extends Task
{
public function configure()
{
// Setup eg. dependency container, load config,...
}
public function run()
{
// Do the real work here.
}
}
// Add the task to the pool
$pool->add(new MyTask());
so i try do like this
use Spatie\Async\Task;
use Spatie\Async\Pool;
class MyTask extends Task
{
public function configure()
{
// Setup eg. dependency container, load config,...
$this->example = array(3,6,5,2,4,9,7,1,9,2,2,3,1,4,2,3,6,5,2,4,9,7,1,9,2,2,3,1,4,2,3,6,5,2,4,9,7,1);
}
public function run()
{
// Do the real work here.
foreach($this->example as $i) {
sleep($i);
echo $i;
}
}
}
// Add the task to the pool
$pool = Pool::create();
$pool->add(new MyTask());
$pool->wait();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I read async can do task
so i try do like this
why it's not working ? and how ?
Beta Was this translation helpful? Give feedback.
All reactions