Dupe: return statement in a lock procedure: inside or outside
The title is a little misleading. I know that you can do it, but I\'m wondering about
Yes, but why not use Dequeue?
Remember lock is simply shorthand for essentially something along the lines of:
try { Monitor.Enter(QueueModifierLockObject); DownloadFile toReturn = queue.Dequeue(); return toReturn; } finally { Monitor.Exit(QueueModifierLockObject); }