diff --git a/src/Geant4Worker/Geant4Worker.ts b/src/Geant4Worker/Geant4Worker.ts index 7f148bf95..d097a39ac 100644 --- a/src/Geant4Worker/Geant4Worker.ts +++ b/src/Geant4Worker/Geant4Worker.ts @@ -154,6 +154,11 @@ export default class Geant4Worker { ); } + cancel() { + this.markSafeForTermination(); + this.state = StatusState.CANCELED; + } + markSafeForTermination() { // we can delay the call should it be needed in the future this.destroy(); diff --git a/src/services/Geant4LocalWorkerSimulationService.ts b/src/services/Geant4LocalWorkerSimulationService.ts index 6ab23b8c7..2d177d8a0 100644 --- a/src/services/Geant4LocalWorkerSimulationService.ts +++ b/src/services/Geant4LocalWorkerSimulationService.ts @@ -536,6 +536,12 @@ export default class Geant4LocalWorkerSimulationService implements SimulationSer } cancelJob(info: SimulationInfo, signal?: AbortSignal | undefined): Promise { - throw new Error('Method not implemented.'); + const { jobId } = info; + + if (this.workers.hasOwnProperty(jobId)) { + this.workers[jobId].cancel(); + } + + return Promise.resolve(); } }