R
Rajat
Hi,
Sorry for the long class. This time I am sending you much cleaner code.
Could you please respond me back, about "how to apply the threading", taking
the example of following scenario .
namespace ThreadingTest
{
public class Class1
{
public event EventHandler raiseResponse; //Event through which I can send
the received data
DataFeeder instDataFeeder = new DataFeeder(); //Object created
for the datafeeder component.
//Constructor
public Class1
{
//CustomEventHandler is the delegate to handle ResponseData event from the
DataFeeder component
instDataFeeder.ResponseData += new
CustomEventHandler(InstDataFeeder_ResponseData);
}
public void RequestData()
{
instDataFeeder.RequestDataFromRemoteServer();
}
public void InstDataFeeder_ResponseData(NewDataStructure newData) //
NewDataStructure contains multiple rows of data at the same time
{
//we receive this event really really really fast and I was
thinking of putting this event on the separate thread.
//Fill Datatable viz. dataTable1 from newData and then raise
event
If(raiseResponse != null)
raiseResponse(dataTable1,EventArgs.Empty); //
Sending the datatable in sender to avoid creating a custom class for event
argument.
}
}
//In the following usercontrol we need to bind the data received from our
own event -- raiseResponse
public class GridControl : System.Windows.Forms.UserControl
{
private DataGrid dataGrid1 = new DataGrid();
Class1 instClass1 = new Class1();
DataTable dt = new DataTable() ; //It has some of the same
columns received from the other class, Not creating the full structure for
the table.
//Constructor
public GridControl ()
{
instClass1. raiseResponse += new
EventHandler(instClass1_raiseResponse);
dataGrid1.DataSource = dt;
}
public void instClass1_raiseResponse(object sender,EventArgs e)
{
//If the data is coming up very fast then there will be problem
updating the UI and UI will freeze.
dataGrid1.SuspendLayout()
DataTable dt = (DataTable) sender; // I think assigning to the
datatable will update the datagrid.
dataGrid1.ResumeLayout()
}
}
}
Please help.
Regards,
Rajat.
Sorry for the long class. This time I am sending you much cleaner code.
Could you please respond me back, about "how to apply the threading", taking
the example of following scenario .
namespace ThreadingTest
{
public class Class1
{
public event EventHandler raiseResponse; //Event through which I can send
the received data
DataFeeder instDataFeeder = new DataFeeder(); //Object created
for the datafeeder component.
//Constructor
public Class1
{
//CustomEventHandler is the delegate to handle ResponseData event from the
DataFeeder component
instDataFeeder.ResponseData += new
CustomEventHandler(InstDataFeeder_ResponseData);
}
public void RequestData()
{
instDataFeeder.RequestDataFromRemoteServer();
}
public void InstDataFeeder_ResponseData(NewDataStructure newData) //
NewDataStructure contains multiple rows of data at the same time
{
//we receive this event really really really fast and I was
thinking of putting this event on the separate thread.
//Fill Datatable viz. dataTable1 from newData and then raise
event
If(raiseResponse != null)
raiseResponse(dataTable1,EventArgs.Empty); //
Sending the datatable in sender to avoid creating a custom class for event
argument.
}
}
//In the following usercontrol we need to bind the data received from our
own event -- raiseResponse
public class GridControl : System.Windows.Forms.UserControl
{
private DataGrid dataGrid1 = new DataGrid();
Class1 instClass1 = new Class1();
DataTable dt = new DataTable() ; //It has some of the same
columns received from the other class, Not creating the full structure for
the table.
//Constructor
public GridControl ()
{
instClass1. raiseResponse += new
EventHandler(instClass1_raiseResponse);
dataGrid1.DataSource = dt;
}
public void instClass1_raiseResponse(object sender,EventArgs e)
{
//If the data is coming up very fast then there will be problem
updating the UI and UI will freeze.
dataGrid1.SuspendLayout()
DataTable dt = (DataTable) sender; // I think assigning to the
datatable will update the datagrid.
dataGrid1.ResumeLayout()
}
}
}
Please help.
Regards,
Rajat.