コード例 #1
0
 public void MergeNullSources_Fact()
 {
     CancellationSource.Merge(null, null)
     .ShouldBeNull();
     CancellationSource.Merge(CancellationSource.Canceled, null)
     .ShouldEqual(CancellationSource.Canceled);
     CancellationSource.Merge(null, CancellationSource.Canceled)
     .ShouldEqual(CancellationSource.Canceled);
 }
コード例 #2
0
        public void MergeAndCancelSecond_Fact()
        {
            var source1 = new CancellationSource();
            var source2 = new CancellationSource();
            var merged  = CancellationSource.Merge(source1, source2);

            source2.Cancel();
            source1.IsCancelationRequested.ShouldBeFalse();
            source2.IsCancelationRequested.ShouldBeTrue();
            merged.IsCancelationRequested.ShouldBeTrue();
            //ensure safety in calling other cancels
            source1.Cancel();
            merged.Cancel();
        }
コード例 #3
0
ファイル: CancellationToken.cs プロジェクト: valoni/uScoober
 public static CancellationSource operator +(CancellationToken token1, CancellationToken token2)
 {
     return(CancellationSource.Merge(token1._source, token2._source));
 }