This[
^] article contains information on how to pass information back using
IAsyncResult
.
Create the DataTableEventArgs in your source project
public class DataTableEventArgs : System.EventArgs {
DataTable dataTable;
public DataTable DataTableInfo {
get {
return dataTable;
}
}
public DataTableEventArgs(DataTable dataTable) {
this.dataTable= dataTable;
}
}
Declare the delegate in your source project
public delegate void DataTableEventHandler(object sender, DataTableEventArgs e);
Declare the event in the class that returns the DataTable
public event DataTableEventHandler ReturnDataTable;
Raise the event where you want to send the DataTable
if (ReturnDataTable != null) {
DataTable dataTable = BuildDataTable();
ReturnDataTable(this, dataTable);
}
Now, in your receiver class that must receive the DataTable
private void Init() {
MyDataSource src = new MyDataSource();
src.ReturnDataTable += new DataTableEventHandler(HandleDataTable);
}
private void HandleDataTable(object sender, DataTableEventArgs e) {
DataTable dataTable = e.DataTableInfo;
}