I am building a Winforms Application that does multiple checks on a DB containing sensitive data.
the DB is updating in high frequency 24/7, so the application will check the DB 24/7. The highest requirement I have is to build the application modular. That implies that if I need to add additional checks to the application in the future, I can add this with high confidence that i am not messing up the existing checks. In addition, every check need to be able to Enable/Disable by itself.
I thought to do that by building additional Check Box & Timer combo for each check in the application. In that way, any additional check is independent (have its own timer and logic) and adding a new check will not change a single line of code in the existing checks.
Code (Test application):
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void check1CheckBox_CheckedChanged(object sender, EventArgs e)
{
check1Timer.Enabled = check1CheckBox.Checked;
}
private void check2CheckBox_CheckedChanged(object sender, EventArgs e)
{
check2Timer.Enabled = check2CheckBox.Checked;
}
private void check3CheckBox_CheckedChanged(object sender, EventArgs e)
{
check3Timer.Enabled = check3CheckBox.Checked;
}
private void check1Timer_Tick(object sender, EventArgs e)
{
check1(); //check DB data
}
private void check2Timer_Tick(object sender, EventArgs e)
{
check2(); //check DB data
}
private void check3Timer_Tick(object sender, EventArgs e)
{
check3(); //check DB data
}
}
I have 2 questions: 1. If in the method explained above, every check is independent and have no way to interrupt/mess with the other checks? 2. What is the "cost" of adding many timers (10+) running in the same time, either in stability/ responsiveness/ timing?
None of the timers will block the form for a long time, every time consuming DB call will be Async (by await calls).
In practice: most of the checks need to run in 2-5 seconds frequency, the maximum frequency will be every second. Every check have is own frequency and veriables.
Thank you.