I have a foreach
loop that is looping through an entity framework result. Each result is being passed through a function. So to catch any errors I have a try/catch
block setup.
Something like this:
foreach (var resetReq in query)
{
try
{
Console.WriteLine("Attemtping password reset for: " + resetReq.uname);
if (adTools.resetPassword(resetReq.uname, resetReq.agentUCID))
{
Console.WriteLine("Password reset for: " + resetReq.uname);
using (var updateDB = new resetDB())
{
Request r = updateDB.Requests.First(x => x.id == resetReq.id);
r.reqCompletedDate = DateTime.Now;
r.completed = 1;
updateDB.SaveChanges();
Console.WriteLine("Reset record for: " + resetReq.uname +
" updated successfully to reflect completion.");
}
}
}
catch (Exception ex)
{
mailFunctions mailFunc = new mailFunctions();
mailFunc.sendMail(ex);
continue;
}
}
My question is, will the continue
statement in my catch block function properly?
Meaning once the exception is thrown and my mail function is fired off, will it continue to loop?