public function OnStartForking()
 {
     $TaskQueue = TaskQueue::GetInstance();
     $offset = 0;
     while ($Task = $TaskQueue->Peek($offset)) {
         // Find handler that would accept the task
         $handledAndRemoved = false;
         foreach ($this->handlers as $Handler) {
             if ($Handler->Accept($Task)) {
                 // This handler is responsible to make task job
                 try {
                     // Do it dear
                     $Handler->Handle($Task);
                 } catch (Exception $e) {
                     Log::Log(sprintf(_("Task handler fails. %s"), $e->getMessage()), E_USER_ERROR);
                 }
                 // When task has no more targets it's complete
                 if (!$Task->HasActiveTargets()) {
                     // Send report about success/fails
                     try {
                         $Handler->Report($Task);
                     } catch (Exception $e) {
                         Log::Log(sprintf(_("Task report failed. %s"), $e->getMessage()), E_USER_ERROR);
                     }
                     // Remove task from queue
                     $TaskQueue->Remove($Task);
                     $handledAndRemoved = true;
                 }
             }
         }
         if (!$handledAndRemoved) {
             $offset++;
         }
     }
 }
                 $err[] = $e->getMessage();
             }
         }
     }
     if (!$err) {
         if (!($post_registrant || $post_admin || $post_billing || $post_tech)) {
             $errmsg = sprintf(_("No contacts were selected"));
         } else {
             if (!$_SESSION['BU_TLD']) {
                 $errmsg = sprintf(_("No domain extension was selected"));
             } else {
                 if (!$_SESSION['BU_DOMAINS']) {
                     $errmsg = sprintf(_("No domains were selected"));
                 } else {
                     // Create bulk update task abd put in into tasks queue
                     $Queue = TaskQueue::GetInstance();
                     try {
                         // Define contact clids list
                         $clids = array(CONTACT_TYPE::REGISTRANT => $post_registrant, CONTACT_TYPE::ADMIN => $post_admin, CONTACT_TYPE::TECH => $post_tech, CONTACT_TYPE::BILLING => $post_billing);
                         // Construct task
                         $Task = new Task($_SESSION['userid'], new BulkUpdateContactJob($_SESSION['BU_TLD'], $clids), $_SESSION['BU_DOMAINS']);
                         $Queue->Put($Task);
                         CoreUtils::Redirect("bulk_update_complete.php");
                     } catch (Exception $e) {
                         $errmsg = $e->getMessage();
                     }
                 }
             }
         }
     }
 }
 protected function CreateTask()
 {
     try {
         // Create task and enqueue it in epp-drs system queue.
         // Task will be handled in TaskQueueProcess.
         $Task = new Task($_SESSION['userid'], new BulkRegisterDomainJob($this->GetTLDs(), $this->periods, $this->contact_list, $this->ns, $this->extra), $this->domains);
         $Queue = TaskQueue::GetInstance();
         $Queue->Put($Task);
         CoreUtils::Redirect("bulk_update_complete.php");
     } catch (Exception $e) {
         $this->display["err"] = $e->getMessage();
     }
 }