Esempio n. 1
0
 public void GiveInvokerTo(InvokeManager target, Invoker item)
 {
     // If an invoke is not required for the target then it is running on the same thread as us.
     if (target.InvokeRequired())
     {
         this.InvokeMethod(() => { SynchronousGiveInvokerTo(target, item); });
     }
     else
     {
         // We can just reassign it since the thread runs both objects.
         target._invokers.Add(item);
         this._invokers.Remove(item);
     }
 }
Esempio n. 2
0
 private void SynchronousGiveInvokerTo(InvokeManager target, Invoker item)
 {
     if (_invokers.Contains(item))
     {
         target.SynchronousInvokeMethod(() =>
         {
             target._invokers.Add(item);
             this._invokers.Remove(item);
             item.ChangeThreadOwner();
         });
     }
     else
     {
         throw new InvalidOperationException(string.Format("Invoker {0} is not owned by {1}.", item.ToString(), this.ToString()));
     }
 }