In my project, i have to do something much much times in a foreach loop which i need to wait it about 6-7 hours.
for example: i have 80 docs to check => about 8 hours
foreach (var doc in docs) { bool valid = checkIsValid(doc); // about 2 min per doc if (vaid) { doThing(doc); // about 5 min per doc } else { delete(doc); // about 20s per doc } } So, i consider can i check these things in the same time which i have lots of resources is not using when running the above code. And i find C# has a multithread feature (i don't know what can it provides).
Can i use it in my project? How to use it in my project?
ideal: 80 docs are checking in the same time and the foreach loop will finish when 80 threads have died.
foreach (var doc in docs) { //new thread start bool valid = checkIsValid(doc); // about 2 min per doc if (vaid) { doThing(doc); // about 5 min per doc } else { delete(doc); // about 20s per doc } //thread die }