Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ExecuteCallbackHandlers()

void System.Threading.CancellationTokenSource.ExecuteCallbackHandlers ( bool throwOnFirstException)
inlineprivateinherited

Definition at line 570 of file CancellationTokenSource.cs.

571 {
572 Registrations registrations = Interlocked.Exchange(ref _registrations, null);
573 if (registrations == null)
574 {
575 Interlocked.Exchange(ref _state, 2);
576 return;
577 }
578 registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId;
579 List<Exception> list = null;
580 try
581 {
582 while (true)
583 {
584 registrations.EnterLock();
585 CallbackNode callbacks;
586 try
587 {
588 callbacks = registrations.Callbacks;
589 if (callbacks == null)
590 {
591 break;
592 }
593 if (callbacks.Next != null)
594 {
595 callbacks.Next.Prev = null;
596 }
597 registrations.Callbacks = callbacks.Next;
598 registrations.ExecutingCallbackId = callbacks.Id;
599 callbacks.Id = 0L;
600 goto IL_0080;
601 }
602 finally
603 {
604 registrations.ExitLock();
605 }
606 IL_0080:
607 try
608 {
609 if (callbacks.SynchronizationContext != null)
610 {
611 callbacks.SynchronizationContext.Send(delegate(object s)
612 {
613 CallbackNode callbackNode = (CallbackNode)s;
614 callbackNode.Registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId;
615 callbackNode.ExecuteCallback();
616 }, callbacks);
617 registrations.ThreadIDExecutingCallbacks = Environment.CurrentManagedThreadId;
618 }
619 else
620 {
621 callbacks.ExecuteCallback();
622 }
623 }
624 catch (Exception item) when (!throwOnFirstException)
625 {
626 (list ?? (list = new List<Exception>())).Add(item);
627 }
628 }
629 }
630 finally
631 {
632 _state = 2;
633 Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0L);
634 }
635 if (list == null)
636 {
637 return;
638 }
639 throw new AggregateException(list);
640 }
void Add(TKey key, TValue value)

References System.Threading.CancellationTokenSource._registrations, System.Threading.CancellationTokenSource._state, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Environment.CurrentManagedThreadId, System.Threading.Interlocked.Exchange(), System.item, System.L, System.list, and System.s.

Referenced by System.Threading.CancellationTokenSource.NotifyCancellation().