Logo

Programming-Idioms

Interrupt an ongoing processing p.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import "context"
ctx, cancel := context.WithCancel(context.Background())
go p(ctx)

somethingElse()

cancel()
uses Process;
var
  P: TProcess;
begin
  ...
  P.Execute;
  //do something else
  P.Terminate(0);
end.
use Coro;
my $coro = async {
   # do work
};
 
$coro->cancel;  # or $coro->safe_cancel