Yes, that will ensure you have at most two tasks running at the same time. Assuming that no other process or task is doing any uploads to that server, you should be fine.
I would suggest to use a semaphore inside your foreach loop instead, because then the actual processing can be done with more than two tasks at the same time. This improves performance if the processing is the part that takes most time.