Пример #1
0
 /// <summary>
 /// FOR INTERNAL USE ONLY!
 /// </summary>
 internal void MaybeLinkSourceInternal(Internal.CancelationRef cancelationRef)
 {
     if (CanBeCanceled)
     {
         _ref.AddLinkedCancelation(cancelationRef);
     }
 }
Пример #2
0
        /// <summary>
        /// Create a new <see cref="CancelationSource"/> that will be canceled either when you cancel it, or when any of the given tokens are canceled (with the same value), whichever is first.
        /// <para/>Note: the new <see cref="CancelationSource"/> still must be disposed when you are finished with it.
        /// </summary>
        /// <param name="tokens">An array that contains the cancelation token instances to observe.</param>
        /// <returns>A new <see cref="CancelationSource"/> that is linked to the source token.</returns>
        public static CancelationSource New(params CancelationToken[] tokens)
        {
            ValidateThreadAccess(1);
            CancelationSource newCancelationSource = New();

            Internal.CancelationRef newCancelation = newCancelationSource._ref;
            for (int i = 0, max = tokens.Length; i < max & !newCancelation.IsCanceled; ++i)
            {
                tokens[i].MaybeLinkSourceInternal(newCancelation);
            }
            return(newCancelationSource);
        }
 /// <summary>
 /// FOR INTERNAL USE ONLY!
 /// </summary>
 internal CancelationRegistration(Internal.CancelationRef cancelationRef, Internal.ICancelDelegate cancelDelegate)
 {
     _ref   = cancelationRef;
     _id    = _ref.TokenId;
     _order = _ref.Register(cancelDelegate);
 }
Пример #4
0
 private CancelationSource(Internal.CancelationRef cancelationRef)
 {
     _ref = cancelationRef;
     _id  = _ref.SourceId;
 }
Пример #5
0
 /// <summary>
 /// FOR INTERNAL USE ONLY!
 /// </summary>
 internal CancelationToken(Internal.CancelationRef cancelationRef)
 {
     _ref = cancelationRef;
     _id  = _ref.TokenId;
 }