我在通信线程里接收到数据的时候添加的数据,在主线程里添加的事件,程序大概是这样的 public void delegate UpdateMsgListDelegate(string str);
public event UpdateMsgListDelegate updateMsg;
MainWindow()
{
this.updateMsg += new UpdateMsgListDelegate(OnRecvdMsg);
}private void OnRecvdMsg(string str)
{
if ( updateMsg != null )
this.dispatch.BeginInvoke(AddMsg, str);
}private void AddMsg(string str)
{
BindList.Add(str); //BindList 是ListBox1绑定的数据集
ListBox1.selectIndex = BindList.count - 1;
ListBox1.ScrollIntoView(ListBox1.selectItem); //我希望能够自动滚屏
}
public event UpdateMsgListDelegate updateMsg;
MainWindow()
{
this.updateMsg += new UpdateMsgListDelegate(OnRecvdMsg);
}private void OnRecvdMsg(string str)
{
if ( updateMsg != null )
this.dispatch.BeginInvoke(AddMsg, str);
}private void AddMsg(string str)
{
BindList.Add(str); //BindList 是ListBox1绑定的数据集
ListBox1.selectIndex = BindList.count - 1;
ListBox1.ScrollIntoView(ListBox1.selectItem); //我希望能够自动滚屏
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货