diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-11 16:54:02 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-11 16:54:02 +0300 |
commit | 475d981364aa18ba22d4d2f78f837d20af4df6a8 (patch) | |
tree | dfbe96d775cd1129a17de33c21c946ba2eeb1d6b /CancellationDisposable.cs | |
parent | 3be35e28f6e1c4477772ab74a18cbbdb45046224 (diff) | |
parent | e7d3fe2beae326a2380b4cfed7f33961f40d87ca (diff) |
Merge branch 'dev'
Diffstat (limited to 'CancellationDisposable.cs')
-rw-r--r-- | CancellationDisposable.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/CancellationDisposable.cs b/CancellationDisposable.cs new file mode 100644 index 0000000..700a2c2 --- /dev/null +++ b/CancellationDisposable.cs @@ -0,0 +1,38 @@ +using System; +using System.Threading; + +namespace Rehau.Sku.Assist +{ + sealed class CancellationDisposable : IDisposable + { + + readonly CancellationTokenSource cts; + public CancellationDisposable(CancellationTokenSource cts) + { + if (cts == null) + { + throw new ArgumentNullException("cts"); + } + + this.cts = cts; + } + + public CancellationDisposable() + : this(new CancellationTokenSource()) + { + } + + public CancellationToken Token + { + get { return cts.Token; } + } + + public void Dispose() + { + cts.Cancel(); + } + } + +} + + |