Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #229 Cancel an operation

Interrupt an ongoing processing p.

p.interrupt();
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

New implementation...
< >
programming-idioms.org