Answers.Body: <p>Sub-tasks can only be initiated by the parent task, and they will only visually look like a sub-task if they are actually sub-tasks.</p>
  
  <p>It’s also not possible to change the settings of an already-running task, at least without manually checking for new settings in your task.</p>
  
  <p>So, your parent task’s <code>getStep()</code> function would need to do its own checking to see if it should be running a sub-task, somehow, and then conditionally call <code>$this-&gt;runSubTask()</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T12:58:02.383Z
Answers.Text: Sorry..., I think my question was confusing (note-to-self: never ask questions when tired). I hope it's clearer now, could you take a look again? Thanks a lot. :)
Answers.UserDisplayName: Victor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T19:17:23.397Z
Answers.Text: Got it. Just updated my answer.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T19:19:25.660Z
Answers.Text: Thanks. But is it possible to pass data to a running task? Or would I need to use a Record and check on each run?
Answers.UserDisplayName: Victor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T19:28:39.897Z
Answers.Text: @VictorIn Updated once again.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T05:41:24.563Z
Answers.LastActivityDate: 2014-06-26T19:28:28.550Z
Answers.LastEditDate: 2014-06-26T19:28:28.550Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I have a plugin which creates a task every time a specify form is submited. Now I want to create a WrapperTask and run each of those tasks as a subTask:</p>
  
  <p><img src="https://i.sstatic.net/4BfXm.jpg" alt="Craft Task with running sub tasks"></p>
  
  <p>I know that I can create a sub-task within the WrapperTask by using <code>$this-&gt;runSubTask</code>, but how can I add a subTask to an already running WrapperTask from outside (the service for example)? Or at least send a new settings-array to an already running Task?</p>
  
  <p><strong>Example:</strong></p>
  
  <ol>
  <li>User submits form</li>
  <li>Service creates WrapperTask</li>
  <li>Service adds subTask to WrapperTask</li>
  <li>Nothing happens for some time</li>
  <li>User submits form again</li>
  <li>Service checks if WrapperTask is still running, and adds subTask</li>
  </ol>
  
  <p>.</p>
  
  <p>If that's not possible, can I at least show them visually as subtasks of my plugin in the task-list?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-26T22:12:33.587Z
Comments.Text: I rolled you over 2k. :-)
Comments.UserDisplayName: nicael
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-26T22:17:20.187Z
Comments.Text: Suggesting to read about your new [privilege](http://craftcms.stackexchange.com/help/privileges/moderator-tools)
Comments.UserDisplayName: nicael
Tags: <plugin-development><tasks>
Title: How to add a subTask to an already running Task?
ThreadText: # How to add a subTask to an already running Task?
  
  (Asked by: username_0 on 2014-06-25)
  
  I have a plugin which creates a task every time a specify form is submited. Now I want to create a WrapperTask and run each of those tasks as a subTask:
  
  ![Craft Task with running sub tasks](https://i.sstatic.net/4BfXm.jpg)
  
  I know that I can create a sub-task within the WrapperTask by using `$this->runSubTask`, but how can I add a subTask to an already running WrapperTask from outside (the service for example)? Or at least send a new settings-array to an already running Task?
  
  **Example:**
  
  1. User submits form
  2. Service creates WrapperTask
  3. Service adds subTask to WrapperTask
  4. Nothing happens for some time
  5. User submits form again
  6. Service checks if WrapperTask is still running, and adds subTask
  
  .
  
  If that's not possible, can I at least show them visually as subtasks of my plugin in the task-list?
  
  **Tags:** plugin-development, tasks
  
  > **Comments:**
  > **username_1**: I rolled you over 2k. :-)  
  > **username_1**: Suggesting to read about your new [privilege](http://craftcms.stackexchange.com/help/privileges/moderator-tools)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2014-06-26. Score: 7 | Accepted answer
  
  Sub-tasks can only be initiated by the parent task, and they will only visually look like a sub-task if they are actually sub-tasks.
  
  It’s also not possible to change the settings of an already-running task, at least without manually checking for new settings in your task.
  
  So, your parent task’s `getStep()` function would need to do its own checking to see if it should be running a sub-task, somehow, and then conditionally call `$this->runSubTask()`.
  
  > **Comments:**
  > **username_0**: Sorry..., I think my question was confusing (note-to-self: never ask questions when tired). I hope it's clearer now, could you take a look again? Thanks a lot. :)  
  > **username_2**: Got it. Just updated my answer.  
  > **username_0**: Thanks. But is it possible to pass data to a running task? Or would I need to use a Record and check on each run?  
  > **username_2**: @VictorIn Updated once again.  
  
  ---
  
  