Exemplo n.º 1
0
 /// <summary>
 /// Adds a transfer to the queue, recommended for load balancing.
 /// Transfer related exceptions are reported through the <see cref="TransferFailed"/> event.
 /// Non-related errors will be thrown to the calling thread.
 /// </summary>
 /// <param name="transfer">the transfer to add to queue</param>
 /// <param name="requeue">If true, the transfer will be requeued even if it's already in the queue.</param>
 /// <returns>True if the item was successfully added to queue</returns>
 public bool Enqueue(Transfer transfer, bool requeue = false)
 {
     transfer.State = TransferState.Waiting;
     if (_queued.Any(x => x.BlobName == transfer.BlobName && x.Mode == transfer.Mode))
     {
         if (!requeue)
         {
             return(false);
         }
     }
     _queued.Enqueue(transfer);
     return(true);
 }