I have a console app that is basically doing this:
foreach (var database in databases)
{
using (var db = new MyDbContext(database.Name))
{
//do some calculations, inserting of thousands of rows, removing thousands of rows, etc
}
}
All works fine. But I want to improve it. So I was thinking of processing multiple databases at the same time. The number of databases I currently have is about 100 and is growing with time. So I think Parallel.ForEach will be too expensive. What is the best approach?