Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass CancellationToken To RunAsync and ReadAsync #230

Closed
khalidabuhakmeh opened this issue Oct 29, 2020 · 3 comments · Fixed by #231
Closed

Pass CancellationToken To RunAsync and ReadAsync #230

khalidabuhakmeh opened this issue Oct 29, 2020 · 3 comments · Fixed by #231
Labels
enhancement New feature or request
Milestone

Comments

@khalidabuhakmeh
Copy link
Contributor

Use case(s)

Some processes are long-running tasks, and the ability to kill these processes might be a good thing. I have a process that starts playing an audio file and I'd like to stop the audio with a cancellationToken.

Description

            var audio = await SimpleExec.Command.ReadAsync(
                "afplay",
                string.Join(" ", arguments),
                noEcho: true,
                cancellationToken: cancellationToken
            );

The issue is that the cancellation request needs to call process.Kill or else the process continues to run in the background.

Alternatives

Handroll starting a process.

Additional context

I'll try and make an attempt myself at implementing the change, but my async foo is mediocre at best.

@khalidabuhakmeh khalidabuhakmeh added the enhancement New feature or request label Oct 29, 2020
khalidabuhakmeh added a commit to khalidabuhakmeh/simple-exec that referenced this issue Oct 29, 2020
This allows folks to kill the running process
using a CancellationTokenSource and its token (I think).

Might need a set of eyeballs on this PR though. adamralph#230
khalidabuhakmeh added a commit to khalidabuhakmeh/simple-exec that referenced this issue Oct 29, 2020
This allows folks to kill the running process
using a CancellationTokenSource and its token (I think).

Might need a set of eyeballs on this PR though. adamralph#230
adamralph pushed a commit to khalidabuhakmeh/simple-exec that referenced this issue Oct 31, 2020
This allows folks to kill the running process
using a CancellationTokenSource and its token (I think).

Might need a set of eyeballs on this PR though. adamralph#230
@adamralph adamralph linked a pull request Nov 2, 2020 that will close this issue
@adamralph adamralph added this to the 6.4.0 milestone Nov 22, 2020
@adamralph adamralph reopened this Nov 25, 2020
@adamralph
Copy link
Owner

Re-opening this, to consider whether Run and Read should also accept a CancellationToken as per @danielmarbach's suggestion in #238.

@adamralph
Copy link
Owner

adamralph commented Dec 5, 2020

Decided to support CancellationToken only in the async methods, and not in the sync methods.

@adamralph
Copy link
Owner

Released in 6.4.0-rc.1.

@khalidabuhakmeh please give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants