【发布时间】:2012-08-14 10:25:09
【问题描述】:
我可以通过写作从我的应用程序中发送消息
port.WriteLine("AT+CMGS=\"" + m.Groups[2].Value + "\"");
port.Write(txt_msgbox.Text + char.ConvertFromUtf32(26));
这很好。但现在我想向一组号码发送批量消息。我有这个循环向一组数字发送消息:
foreach (ListViewItem item in bufferedListView1.Items)
{
string lname = bufferedListView1.Items[i].Text;
string lno = bufferedListView1.Items[i].SubItems[1].Text;
string gname = bufferedListView1.Items[i].SubItems[2].Text;
string line = lname + "@" + lno + "@" + gname;
if (gname.Contains(sgroup))
{
var m = Regex.Match(line, @"([\w]+)@([+\d]+)@([\w]+)");
if (m.Success)
{
port.WriteLine("AT+CMGS=\"" + m.Groups[2].Value + "\"");
port.Write(txt_msgbox.Text + char.ConvertFromUtf32(26));
Thread.Sleep(4000);
}
sno++;
}
i++;
}
这也很有效。但问题出在 UI 上,在相当长的一段时间内变得反应迟钝。有什么更好的方法吗?
【问题讨论】:
标签: c# multithreading sms serial-port