111,096
社区成员




public frmTailInBox()//构造函数
{
ShowCoatInfoInDgv = (cci) =>
{
DataRow[] drs = m_dtCoatTail.Select(string.Format(@"CoatId='{0}'", cci.SourceCode));
if (drs.Length == 0)
{
m_dtCoatTail.Rows.Add(new object[] { cci.SourceCode, cci.CoatCode, "", "", "" });
if (dgvCoatTail.Rows.Count > 0)
{
dgvCoatTail.FirstDisplayedScrollingRowIndex = dgvCoatTail.Rows.Count - 1;
dgvCoatTail.ClearSelection();
}
}
};
}
public void Reader2_OnReadEpc_6C_800(sender s ,envent){
......
if (cci.CoatCode != null)
{
this.InvokeExAction<Control, CoatCardInfo>(ShowCoatInfoInDgv, cci);}
}
在上面红色代码处是从一个线程(Reader2_OnReadEpc_6C_800)向UI线程显示数据 但是这里报错
}
public static void InvokeExAction<T, TPrams1>(this T @this, Action<TPrams1> action, TPrams1 p1)
where T : Control
{
if (@this.InvokeRequired)
{
@this.Invoke(action, new object[] { p1 });
}
else
{
if (!@this.IsHandleCreated)
return;
if (@this.IsDisposed)
//throw new ObjectDisposedException("@this is disposed.");
return;
action(p1);
}
}