1 Reply Latest reply on Feb 3, 2016 11:38 PM by milligramme

    cancelTask() & cancelAllTask()

    eboda_snaf Level 1

      I tried to stop a background exporting job using cancelTask() in my script. But i did not work, so did cancelAllTask().

       

      please advise.Thanks

      cheers.

        • 1. Re: cancelTask() & cancelAllTask()
          milligramme Level 3

          Hi

          in this snippet cancelTask() works for me.

           

           

          var doc = app.documents[0];
          var bg_tasks = app.backgroundTasks;
          
          
          doc.asynchronousExportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/w.pdf"));
          doc.asynchronousExportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/x.pdf"));
          doc.asynchronousExportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/y.pdf"));
          doc.asynchronousExportFile(ExportFormat.PDF_TYPE, new File("~/Desktop/z.pdf"));
          
          
          $.writeln(bg_tasks.length);
          $.writeln(bg_tasks.everyItem().id);
          $.writeln(bg_tasks.everyItem().name);
          $.writeln(bg_tasks.everyItem().percentDone);
          
          
          // cancel w.pdf and y.pdf export
          bg_tasks[0].cancelTask();
          bg_tasks[2].cancelTask();
          
          
          // cancell all background tasks
          // bg_tasks.everyItem().cancelTask();
          

           

          thank you

          mg.