好的,这是提出问题的更好方式:
void PrepareTimers(List<int> _dataValues)
{
foreach (int dataValue in _dataValues)
{
ThreadingTimer timer = new ThreadingTimer(TimerAction, dataValue, 0, 1000);
}
}
void TimerAction(object flag)
{
string myconstring = "SERVER=localhost;" + "DATABASE=alicosms;" + "UID=root;" + "PASSWORD=;";
MySqlConnection mycon = new MySqlConnection(myconstring);
string u = "UPDATED";
mycon.Open();
MySqlCommand cmd = new MySqlCommand("UPDATE sms_data_bankasia set flag= @flag * 2 , sendingstatus = '" + u + "' WHERE flag = @flag", mycon);
MySqlParameter param = new MySqlParameter();
param.ParameterName = "@flag";
param.Value = flag;
cmd.Parameters.Add(param);
cmd.ExecuteNonQuery();
}
ThreadTimer给我一个错误,说“无法找到命名空间/类型”。任何修复?
答案 0 :(得分:3)
框架中没有名为ThreadingTimer
的类型。假设您需要System.Threading.Timer
,则应将using System.Threading;
添加到文件的顶部(如果您还没有),则将ThreadingTimer
替换为Timer
。