Skip to content

Commit 763b1da

Browse files
author
electricessence
authored
Improved use of Interlocked.Exchange for .Cancel
1 parent 5638fff commit 763b1da

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

ActionRunner.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public Exception LastFault
7171
public bool Cancel(bool onlyIfNotRunning)
7272
{
7373
var t = _task;
74-
return t?.Cancel(onlyIfNotRunning) ?? false
75-
&& t == Interlocked.CompareExchange(ref _task, null, t);
74+
return t!=null
75+
&& t == Interlocked.CompareExchange(ref _task, null, t)
76+
&& t.Cancel(onlyIfNotRunning);
7677
}
7778

7879
public bool Cancel()

0 commit comments

Comments
 (0)