示例#1
0
        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()));
        }
示例#2
0
        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);
        }
示例#3
0
 public override int GetHashCode()
 {
     return(context.GetHashCode());
 }
示例#4
0
 public override int GetHashCode()
 {
     return(_syncContext != null?_syncContext.GetHashCode() : 0);
 }