Example #1
0
        // Call this method before starting blocking operation.
        // Dispose result after operation is done.
        public BlockingOperation NewOp()
        {
            lock (this)
            {
                // Try to find free handler
                BlockingOperation o = operations;
                while (o != null)
                {
                    if (o.Thread == null)
                    {
                        o.Thread = Thread.CurrentThread;
                        return(o);
                    }
                    else
                    {
                        o = o.Next;
                    }
                }

                // Create new handler and append other handlers
                o               = operations;
                operations      = new BlockingOperation(Thread.CurrentThread);
                operations.Next = o;
                return(operations);
            }
        }
Example #2
0
 // Abort all blocking operations.
 public void Abort()
 {
     lock (this)
     {
         BlockingOperation o = operations;
         while (o != null)
         {
             if (o.Thread != null)
             {
                 o.Abort();
             }
             o = o.Next;
         }
     }
 }