I just used parallel tasks to decrease the time a process took from over an hour to about 2 minutes. I was wary of creating so many database contexts, but it paid off in a major way!
See the snippet of code below to see how I used the Parallel.ForEach. .Net created almost 100 threads during the execution.
Parallel.ForEach(qry, issue =>
{
using (var _db = new WCO())
{
dobType dob;
List<dobType> birthdays = new List<dobType>();
foreach (
var subIssue in
issue.DOBValue.Trim().Split(new string[] { " TO ", " to ", "-", " - " },
StringSplitOptions.RemoveEmptyEntries))
{
string valueToTest = subIssue;
// Try Month Year regex
if (tryDateFirstPart(valueToTest, out dob))
{
logger.Info(string.Format("Parsed {0} to Month: {1}, Day {2} Year: {3}", issue,
dob.month,
dob.day, dob.year));
saveParseDOB(dob, issue, _db);
}
else
{
logger.Error(string.Format("Could not parse {0}", issue.DOBValue));
}
}
}
});
If you need someone with my ability to decrease processing times on a full time basis, please contact me through LinkedIn
Have a great day!