public void SynchronizationContext_IsEqualToCopyOfItself() { SynchronizationContext synchronizationContext1 = AsyncContext.Run(() => SynchronizationContext.Current); SynchronizationContext synchronizationContext2 = synchronizationContext1.CreateCopy(); Assert.Equal(synchronizationContext1.GetHashCode(), synchronizationContext2.GetHashCode()); Assert.True(synchronizationContext1.Equals(synchronizationContext2)); Assert.False(synchronizationContext1.Equals(new SynchronizationContext())); }
public static void Print([CallerMemberName] string Name = null) { string msg = string.Empty; msg += $"[{Name}]"; msg += $"[Trhead:{Thread.CurrentThread.ManagedThreadId}]"; ExecutionContext ec = ExecutionContext.Capture(); msg += $"EC:{ec?.GetHashCode()}]"; TaskScheduler ts = TaskScheduler.Current; msg += $"TS:{ts?.Id}]"; SynchronizationContext sc = SynchronizationContext.Current; msg += $"SC:{sc?.GetHashCode()}]"; Trace.WriteLine(msg); }
public override int GetHashCode() { return(context.GetHashCode()); }
public override int GetHashCode() { return(_syncContext != null?_syncContext.GetHashCode() : 0); }