Esempio n. 1
0
        public void Invoke(int invocationId, Action action)
        {
            LinkedList <InvocationCache.CachedOperation> obj = this.cache;

            lock (obj)
            {
                bool flag = invocationId < this.nextInvocationId;
                if (!flag)
                {
                    bool flag2 = invocationId == this.nextInvocationId;
                    if (flag2)
                    {
                        this.nextInvocationId++;
                        action();
                        bool flag3 = this.cache.Count > 0;
                        if (flag3)
                        {
                            LinkedListNode <InvocationCache.CachedOperation> linkedListNode = this.cache.First;
                            while (linkedListNode != null && linkedListNode.Value.InvocationId == this.nextInvocationId)
                            {
                                this.nextInvocationId++;
                                linkedListNode.Value.Action();
                                linkedListNode = linkedListNode.Next;
                                this.cache.RemoveFirst();
                            }
                        }
                    }
                    else
                    {
                        InvocationCache.CachedOperation value = new InvocationCache.CachedOperation
                        {
                            InvocationId = invocationId,
                            Action       = action
                        };
                        bool flag4 = this.cache.Count == 0;
                        if (flag4)
                        {
                            this.cache.AddLast(value);
                        }
                        else
                        {
                            for (LinkedListNode <InvocationCache.CachedOperation> linkedListNode2 = this.cache.First; linkedListNode2 != null; linkedListNode2 = linkedListNode2.Next)
                            {
                                bool flag5 = linkedListNode2.Value.InvocationId > invocationId;
                                if (flag5)
                                {
                                    this.cache.AddBefore(linkedListNode2, value);
                                    return;
                                }
                            }
                            this.cache.AddLast(value);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void Invoke(int invocationId, Action action)
 {
     lock (this.cache)
     {
         if (invocationId < this.nextInvocationId)
         {
             return;
         }
         if (invocationId == this.nextInvocationId)
         {
             ++this.nextInvocationId;
             action();
             if (this.cache.Count <= 0)
             {
                 return;
             }
             LinkedListNode <InvocationCache.CachedOperation> linkedListNode = this.cache.First;
             while (linkedListNode != null && linkedListNode.Value.InvocationId == this.nextInvocationId)
             {
                 ++this.nextInvocationId;
                 linkedListNode.Value.Action();
                 linkedListNode = linkedListNode.Next;
                 this.cache.RemoveFirst();
             }
         }
         else
         {
             InvocationCache.CachedOperation cachedOperation = new InvocationCache.CachedOperation()
             {
                 InvocationId = invocationId,
                 Action       = action
             };
             if (this.cache.Count == 0)
             {
                 this.cache.AddLast(cachedOperation);
             }
             else
             {
                 for (LinkedListNode <InvocationCache.CachedOperation> node = this.cache.First; node != null; node = node.Next)
                 {
                     if (node.Value.InvocationId > invocationId)
                     {
                         this.cache.AddBefore(node, cachedOperation);
                         return;
                     }
                 }
                 this.cache.AddLast(cachedOperation);
             }
         }
     }
 }