public void Invoke(int invocationId, Action action)
 {
     lock (this.cache)
     {
         if (invocationId < this.nextInvocationId)
         {
             Debug.Print("InvocationId {0} - ignored", invocationId);
         }
         else if (invocationId == this.nextInvocationId)
         {
             this.nextInvocationId++;
             action();
             if (this.cache.Count > 0)
             {
                 LinkedListNode <CachedOperation> n = this.cache.First;
                 while ((n != null) && (n.Value.InvocationId == this.nextInvocationId))
                 {
                     this.nextInvocationId++;
                     n.Value.Action();
                     n = n.Next;
                     this.cache.RemoveFirst();
                 }
             }
         }
         else
         {
             CachedOperation op = new CachedOperation()
             {
                 InvocationId = invocationId,
                 Action       = action
             };
             if (this.cache.Count == 0)
             {
                 this.cache.AddLast(op);
             }
             else
             {
                 for (LinkedListNode <CachedOperation> node = this.cache.First; node != null; node = node.Next)
                 {
                     if (node.Value.InvocationId > invocationId)
                     {
                         this.cache.AddBefore(node, op);
                         break;
                     }
                 }
                 this.cache.AddLast(op);
             }
         }
     }
 }
示例#2
0
 // Methods
 public void Invoke(int invocationId, Action action)
 {
     lock (this.cache)
     {
         if (invocationId == this.nextInvocationId)
         {
             this.nextInvocationId++;
             action();
             if (this.cache.Count > 0)
             {
                 LinkedListNode <CachedOperation> first = this.cache.First;
                 while ((first != null) && (first.Value.InvocationId == this.nextInvocationId))
                 {
                     this.nextInvocationId++;
                     first.Value.Action();
                     first = first.Next;
                     this.cache.RemoveFirst();
                 }
             }
         }
         else
         {
             CachedOperation operation = new CachedOperation
             {
                 InvocationId = invocationId,
                 Action       = action
             };
             if (this.cache.Count == 0)
             {
                 this.cache.AddLast(operation);
             }
             else
             {
                 for (LinkedListNode <CachedOperation> node2 = this.cache.First; node2 != null; node2 = node2.Next)
                 {
                     if (node2.Value.InvocationId > invocationId)
                     {
                         this.cache.AddBefore(node2, operation);
                         goto Label_010E;
                     }
                 }
                 this.cache.AddLast(operation);
                 Label_010E :;
             }
         }
     }
 }