interrupting a task?

Discussion in 'Plugin Development' started by CaiusTSM, Jul 25, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    CaiusTSM

    How would I interrupt a task and then resume it?
     
  2. Offline

    cholo71796

    What kind of task?
     
  3. Offline

    CaiusTSM

  4. Offline

    bassfader

    You can cancel a scheduled task by using this command (where taskID is an int value, representing the ID of the task, which is returned from scheduleAsyncDelayedTask() and the other similar commands):
    Code:
    getServer().getScheduler().cancelTask(taskID);
    EDIT: But I dont think there is a way to actually pause it, and resume it later. I think you'd need to cancel it and create a new (similar) one later again
     
  5. Offline

    nisovin

    In your Runnable class, just add a boolean variable. In your run() method, check if the boolean is true before doing anything. Then you can just change the value of that boolean from wherever it's needed. It won't technically pause it, but it will prevent it from doing anything until you turn it back on.
     
  6. Offline

    CaiusTSM

    Wow I wonder why I diden't think of the boolean idea...
    Thank guys!
     
Thread Status:
Not open for further replies.

Share This Page