Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2014-04-25 20:02:13 +0400
committerMarek Safar <marek.safar@gmail.com>2014-04-25 20:03:43 +0400
commitb3c6f228b31ca5695f2fcbeecbdb9b5b496ac48c (patch)
tree179b3de120a26bf9341d758aeffa46e9557e5b51 /mcs/class/corlib/System.Threading.Tasks
parent19f49f93f9ec66cfd54b458796c3b0800d6fb9c3 (diff)
[corlib] Fix extra await context switch when custom SynchronizationContext does not change. Fixes #17878
Diffstat (limited to 'mcs/class/corlib/System.Threading.Tasks')
-rw-r--r--mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs b/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs
index b826f309e39..2a0547850bd 100644
--- a/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs
+++ b/mcs/class/corlib/System.Threading.Tasks/TaskContinuation.cs
@@ -161,7 +161,11 @@ namespace System.Threading.Tasks
public void Execute ()
{
- ctx.Post (l => ((Action) l) (), action);
+ // No context switch when we are on correct context
+ if (ctx == SynchronizationContext.Current)
+ action ();
+ else
+ ctx.Post (l => ((Action) l) (), action);
}
}