I'm developing an application to send SMS via AT commands, that part is OK. I have a list of contacts and I want to send a file (which changes in time) to all of my contacts. In order to do that I need to repeat the sending part every 30 minutes. I found this code using a timer, but I'm not sure if it's useful in my case and how I can use it. Please help, any idea is appreciated.
private void btntime_Click(object sender, EventArgs e)
{
s_myTimer.Tick += new EventHandler(s_myTimer_Tick);
int tps = Convert.ToInt32(textBoxsettime.Text);
// 1 seconde = 1000 millisecondes
try
{
s_myTimer.Interval = tps * 60000;
}
catch
{
MessageBox.Show("Error");
}
s_myTimer.Start();
MessageBox.Show("Timer activated.");
}
// Méthode appelée pour l'évènement
static void s_myTimer_Tick(object sender, EventArgs e)
{
s_myCounter++;
MessageBox.Show("ns_myCounter is " + s_myCounter + ".");
if (s_myCounter >= 1)
{
// If the timer is on...
if (s_myTimer.Enabled)
{
s_myTimer.Stop();
MessageBox.Show("Timer stopped.");
}
else
{
MessageBox.Show("Timer already stopped.");
}
}
}