Here is how you can do that (I’m not going to post the actual code because then you wouldn’t learn anything):
- Check Ping
- If Ping is OK, reset counter. If not, increment counter.
- Check when the last time you sent an email was. Send an email if appropriate, don’t if it’s not (e.g. define a minimum time-span between two emails).
Before you start coding, precisely define under which conditions you want to send an email. Write up some use cases (realistic ones and border cases) and test them against your conditions. Redefine / Repeat if necessary.
solved c# if statement && || [closed]