I am new with C#. I am running a loop to send emails to subscribed users. I need to slow down the loop because I only want to send 10 email/second. Is using Thread.sleep good way to slow down the loop? please see code below.
while (rdr.Read())
{
System.Threading.Thread.Sleep(100);
//send email code here
}
Thanks
Why don’t you have a System.Timers.Timer that fires up every second and sends up to ten messages from your message queue every second.
This way you really do have complete control over the process and are not guessing about speed/timings of your email sender.
Perhaps something like this:
In short – no – your original approach is not good.