Example #1
0
        private static void ExecutePending(SafeQueue <Action> queue, RuntimeUniqueIdProdiver.UniqueId id)
        {
            bool didEnter = false;

            try
            {
                didEnter = ReentryGuardHelper.Enter(id);
                if (!didEnter)
                {
                    // called from inside this method - skip
                    return;
                }
                Action action;
                while (queue.TryTake(out action))
                {
                    action.Invoke();
                }
            }
            finally
            {
                if (didEnter)
                {
                    ReentryGuardHelper.Leave(id);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReentryGuard" /> class.
 /// </summary>
 public ReentryGuard()
 {
     _workQueue = new SafeQueue <Action>();
     _id        = RuntimeUniqueIdProdiver.GetNextId();
 }