How can I pass a callback to another method? In my code, i update my
datagrid with the datatable after the method loadAuditFileToTable is
finished executing. Instead, I'd like to be able to to update the grid
continuously (while the table's filling) and someone suggested I pass a
callback to loadAuditFileToTable and run it every X records. How can I do
this? This is a summary of my code:
loadAuditFileToTableDelegate LoadAuditFileToTable = new
loadAuditFileToTableDelegate(loadAuditFileToTable) ;
LoadAuditFileToTable.BeginInvoke (new AsyncCallback(yourCallback), null);
}
delegate void GUIUPdate();
void yourCallback(IAsyncResult iar)
{
if (iar.IsCompleted)
{
dataGrid_auditAddress.Invoke (new GUIUPdate(guiUpdateMethod),null);
}
}
private void guiUpdateMethod()
{
this.dataGrid_auditAddress.DataSource = _table_auditAddress;
}
private void loadAuditFileToTable()
{
ZMMatch.Audit zmAudit = new ZMMatch.Audit(NONE, NONE);
_table_auditAddress = zmAudit.OpenAuditAZMFileToView(_SFileName);
}
public DataTable OpenAuditAZMFileToView(string sFileName)
{
/* ZMMatch class
// open file, create table/columns,etc...
sAuditRecord = sr.ReadLine();
while (sAuditRecord != null)
{
/* Parse/process line, fill row, and add row to table. Loop will add
500,000 rows */
sAuditRecord = sr.ReadLine();
}
return myTable;
}