Beispiel #1
0
        private bool _TryDequeue(out string fullPath)
        {
            fullPath = null;
            var    dirName = _queueRegister.EnsureQueueInitialized(this._inputQueue);
            string fileName;
            bool   loopAgain = false;

            do
            {
                loopAgain = false;
                fullPath  = null;
                fileName  = null;
                string tempPath = null;

                lock (this._filesCacheLock)
                {
                    if (this._filesQueue.TryDequeue(out fileName))
                    {
                        tempPath = Path.Combine(dirName, fileName);
                        this._filesCache.Remove(fileName);
                    }
                    else
                    {
                        return(false);
                    }
                }

                /*
                 * // Check if the file is defered (skip them if not ready for processing)
                 * if (fileName.StartsWith("d") && TransportHelper.GetFileUtcDate(fileName) > DateTime.Now.ToUniversalTime())
                 * {
                 *  loopAgain = true;
                 * }
                 * else
                 */

                if (!TransportHelper.RenameToTempWithLock(tempPath, out fullPath))
                {
                    // this file is used by somebody else (try to get another one)
                    loopAgain = true;
                }
            } while (loopAgain);

            return(true);
        }
 /// <summary>
 /// Creates a "queue" (i.e. a directory) with the given name
 /// </summary>
 public void CreateQueue(string address)
 {
     _queueRegister.EnsureQueueInitialized(address);
 }