1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Collections; 6 using System.Threading; 7 using System.Diagnostics; 8 9 namespace System.ComponentModel 10 { 11 public static class AsyncOperationManager 12 { CreateOperation(object userSuppliedState)13 public static AsyncOperation CreateOperation(object userSuppliedState) 14 { 15 return AsyncOperation.CreateOperation(userSuppliedState, SynchronizationContext); 16 } 17 18 [EditorBrowsable(EditorBrowsableState.Advanced)] 19 public static SynchronizationContext SynchronizationContext 20 { 21 get 22 { 23 if (SynchronizationContext.Current == null) 24 { 25 SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); 26 } 27 28 return SynchronizationContext.Current; 29 } 30 31 // a thread should set this to null when it is done, else the context will never be disposed/GC'd 32 set 33 { 34 SynchronizationContext.SetSynchronizationContext(value); 35 } 36 } 37 } 38 } 39 40 41