diff options
author | Stephen Toub <stoub@microsoft.com> | 2016-04-14 16:35:19 +0300 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2016-04-14 16:35:19 +0300 |
commit | b4be6407b7034f24484a4e252455151798cca91c (patch) | |
tree | 14d32bf0a1210b317dca2c8bdcbad809cd07a335 /src | |
parent | 6444a9c861930899c46ec848b55d6c0cd2240220 (diff) | |
parent | 0ff0ff32ee0be27863d193f60e0d5a2f2596dd78 (diff) |
Merge pull request #7729 from jamesqo/stream-tasks
Use Task.FromCanceled in Stream
Diffstat (limited to 'src')
-rw-r--r-- | src/System.IO/src/System/IO/Stream.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/System.IO/src/System/IO/Stream.cs b/src/System.IO/src/System/IO/Stream.cs index f70d6cd41a..cce242278f 100644 --- a/src/System.IO/src/System/IO/Stream.cs +++ b/src/System.IO/src/System/IO/Stream.cs @@ -247,7 +247,7 @@ namespace System.IO { if (cancellationToken.IsCancellationRequested) { - return new Task(() => { }, cancellationToken); + return Task.FromCanceled(cancellationToken); } return Task.Factory.StartNew(state => ((Stream)state).Flush(), this, @@ -268,7 +268,7 @@ namespace System.IO if (cancellationToken.IsCancellationRequested) { - return new Task<int>(() => 0, cancellationToken); + return Task.FromCanceled<int>(cancellationToken); } // To avoid a race with a stream's position pointer & generating race @@ -304,7 +304,7 @@ namespace System.IO if (cancellationToken.IsCancellationRequested) { - return new Task(() => { }, cancellationToken); + return Task.FromCanceled(cancellationToken); } // To avoid a race with a stream's position pointer & generating race |