Store and reset SynchronizationContext

fixes 2001
Merge pull request #2008 from Particular/Issue_2001_corruptedContext

Store and reset SynchronizationContext