I have a method that looks like this:
public void SomeMethodThatLoadsUserData()
{
Method1();
Method2();
Method3();
.....
Method12();
}
These get executed when the user logs on and each method fetches some data related to the user. I was wondering if making these run in parallel would have any performance benefit because each method ends up calling a query to the same database file. And, if there would be a performance benefit, how would I rewrite this code?
Thanks for your suggestions.
The following code demonstrates a parallel test using a list of Thread and Stopwatch objects. I think this is pretty good method to test with because it guarantees a parallel execution attempt (unlike Parallel.Invoke) and it’s easier to set up than using the ThreadPool IMO.
Output:
Any time saving will show up when (hopefully)
Totalis less than the sum of each method.