void () { for (int i=0; i<1000;i++) { final ProgressIndicatorBase indicator = new ProgressIndicatorBase(); ProgressManager.getInstance().runProcess(() -> { ProgressManager.checkCanceled(); // checkCanceled() must have caught just canceled indicator assertThrows(ProcessCanceledException.class, () -> { indicator.cancel(); ProgressManager.checkCanceled(); }); }, indicator); } }