private void InsertAudit(int index, ScanAuditEventArgs item) { if (lstAudit.InvokeRequired) { InsertText it = InsertAudit; BeginInvoke(it, new object[] { index, item }); } else { lstAudit.Items.Insert(index, item); Application.DoEvents(); } }
private void AddAudit(ScanAuditEventArgs item) { if (lstAudit.InvokeRequired) { AddText it = AddAudit; BeginInvoke(it, new object[] { item }); } else { try { lstAudit.Items.Add(item); if (lstAudit.SelectedItems.Count == 0 && lstAudit.Items.Count > 0) NativeMethods.SendMessage(lstAudit.Handle, NativeMethods.Scroll, NativeMethods.ScrollBottom, 0); //Application.DoEvents(); } catch (Win32Exception) { // ignore as we are more then likely exiting anyway } catch (ObjectDisposedException) { // ignore as we are more then likely exiting anyway } } }
private void OnAuditRaised(object sender, ScanAuditEventArgs e) { if (m_traceAudit.IsReversed) { InsertAudit(0, e); } else { AddAudit(e); //InsertAudit(lstAudit.Items.Count, e); Application.DoEvents(); } }