AT コマンド経由で SMS を送信するアプリケーションを開発していますが、その部分は問題ありません。連絡先のリストがあり、すべての連絡先に (時間とともに変化する) ファイルを送信したいと考えています。そのためには、送信部分を 30 分ごとに繰り返す必要があります。タイマーを使用してこのコードを見つけましたが、私の場合に役立つかどうか、またどのように使用できるかはわかりません。助けてください、どんなアイデアでも大歓迎です。
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.");
}
}
}