mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 18:15:44 +00:00
Extract method for reuse
This commit is contained in:
parent
4baddaab7f
commit
670986dcb2
1 changed files with 9 additions and 10 deletions
|
|
@ -78,23 +78,22 @@ public class FFMpegArgumentProcessor
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FFMpegArgumentProcessor CancellableThrough(out Action cancel, int timeout = 0)
|
private void Cancel(int timeout)
|
||||||
{
|
|
||||||
cancel = () =>
|
|
||||||
{
|
{
|
||||||
_cancelled = true;
|
_cancelled = true;
|
||||||
CancelEvent?.Invoke(this, timeout);
|
CancelEvent?.Invoke(this, timeout);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
public FFMpegArgumentProcessor CancellableThrough(out Action cancel, int timeout = 0)
|
||||||
|
{
|
||||||
|
cancel = () => Cancel(timeout);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
||||||
{
|
{
|
||||||
_cancellationTokenRegistration = token.Register(() =>
|
_cancellationTokenRegistration = token.Register(() => Cancel(timeout));
|
||||||
{
|
|
||||||
_cancelled = true;
|
|
||||||
CancelEvent?.Invoke(this, timeout);
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue