We are implementing TPL (C#) in one of our applications where we are uploading files to server in parallel. When we try to upload 15 files in parallel with MaxdegreeOfParallism set to 4 only 12 files are uploaded and three files are not uploaded. We changed the MaxDegreeOfParallelism to 2 then 14 files are uploaded. I am not sure how does MaxDegreeOfParallelism work. Could any one clarify the use of MaxDegreeOfParallelism and what could be the reason of non processing the files.
My code
Parallel.ForEach(fileCollection,new ParallelOptions{ MaxDegreeOfParallelism = 2 },
number => { fileNumber = UploadFile(file, response); });
Upload function will upload files to AmazonS3.
When we upload the files with MaxDegreeOfParallelism =1 then all files are uploaded properly whereas when we change the MaxDegreeOfParallelism to 2 only 14 files got uploaded out of 15 and if we change to 4 only 12 files got uploaded.
My Development system is quad core window 10.