Hi
I have a network program that fills 4 datatables while receiving data bursts
and which should then show those tables in 4 datagrids. The main GUI class
contains event callbacks for events that the receiver thread throws when
it's being activated and deactivated (handler_Broadc astStart, and
handler_EndOfBr oadcast):
private void handler_Broadca stStart()
{
options.receive rActive = true;
options.Invoke( new EventHandler(op tions.updateGUI ));
this.receiverAc tive = true;
this.dataGrid1. Invoke(new EventHandler(up dateGUI));
Application.DoE vents();
}
private void handler_EndOfBr oadcast()
{
options.receive rActive = false;
options.Invoke( new EventHandler(op tions.updateGUI ));
this.receiverAc tive = false;
this.dataGrid1. Invoke(new EventHandler(up dateGUI));
Application.DoE vents();
}
The main GUI form contains one datagrid, which is bound and unbound to the
datasource (I've tried suspending databindings several times in vain.. maybe
you've some of my other posts to these newsgroups). Here's the code I use
to show the data when the receiver is not active.
public void updateGUI(objec t sender, EventArgs e)
{
if (this.receiverA ctive)
dataGrid1.DataS ource = null;
else
this.display(ha ndler.manager.g etRecords());
}
public void display(DataTab le table)
{
this.table = table;
view = new DataView(this.t able, "", "ID ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid1. DataSource = view;
}
This works just as it should. Now my form to display several options (called
options) contains the other three Datagrids and I try to activate and
deactivate them using a very similar mechanism. You've already seen the
option.Invoke call above, and here's the updateGUI method of the options
form:
public void updateGUI(objec t sender, EventArgs e)
{
if (this.receiverA ctive)
{
dataGrid1.DataS ource = null;
dataGrid2.DataS ource = null;
dataGrid3.DataS ource = null;
}
else
{
this.dataGrid1. DataSource = new DataView(stats. packetsReceived , "", "seqNo
ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid2. DataSource = new DataView(stats. missingPackets, "", "ID
ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid3. DataSource = stats.completio nPercentages;
this.update();
}
}
The problem is, nulling the DataSource works, but binding it again locks up
the GUI. The program is still running, but neither the main GUI form, nor
the options form are accessible anymore and I have to kill them via the task
manager. I've also tried to call Invoke on the 3 datagrids in the options
form directly, without any success, as well as manipulating the DataSource
of those 3 datagrids in the UpdateGUI method of the main GUI class.. all
without success. Any ideas how I can handle those 3 datagrids in my 2nd form
just like the main datagrid?
Regards
Stephan Steiner
I have a network program that fills 4 datatables while receiving data bursts
and which should then show those tables in 4 datagrids. The main GUI class
contains event callbacks for events that the receiver thread throws when
it's being activated and deactivated (handler_Broadc astStart, and
handler_EndOfBr oadcast):
private void handler_Broadca stStart()
{
options.receive rActive = true;
options.Invoke( new EventHandler(op tions.updateGUI ));
this.receiverAc tive = true;
this.dataGrid1. Invoke(new EventHandler(up dateGUI));
Application.DoE vents();
}
private void handler_EndOfBr oadcast()
{
options.receive rActive = false;
options.Invoke( new EventHandler(op tions.updateGUI ));
this.receiverAc tive = false;
this.dataGrid1. Invoke(new EventHandler(up dateGUI));
Application.DoE vents();
}
The main GUI form contains one datagrid, which is bound and unbound to the
datasource (I've tried suspending databindings several times in vain.. maybe
you've some of my other posts to these newsgroups). Here's the code I use
to show the data when the receiver is not active.
public void updateGUI(objec t sender, EventArgs e)
{
if (this.receiverA ctive)
dataGrid1.DataS ource = null;
else
this.display(ha ndler.manager.g etRecords());
}
public void display(DataTab le table)
{
this.table = table;
view = new DataView(this.t able, "", "ID ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid1. DataSource = view;
}
This works just as it should. Now my form to display several options (called
options) contains the other three Datagrids and I try to activate and
deactivate them using a very similar mechanism. You've already seen the
option.Invoke call above, and here's the updateGUI method of the options
form:
public void updateGUI(objec t sender, EventArgs e)
{
if (this.receiverA ctive)
{
dataGrid1.DataS ource = null;
dataGrid2.DataS ource = null;
dataGrid3.DataS ource = null;
}
else
{
this.dataGrid1. DataSource = new DataView(stats. packetsReceived , "", "seqNo
ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid2. DataSource = new DataView(stats. missingPackets, "", "ID
ASC",
DataViewRowStat e.CurrentRows);
this.dataGrid3. DataSource = stats.completio nPercentages;
this.update();
}
}
The problem is, nulling the DataSource works, but binding it again locks up
the GUI. The program is still running, but neither the main GUI form, nor
the options form are accessible anymore and I have to kill them via the task
manager. I've also tried to call Invoke on the 3 datagrids in the options
form directly, without any success, as well as manipulating the DataSource
of those 3 datagrids in the UpdateGUI method of the main GUI class.. all
without success. Any ideas how I can handle those 3 datagrids in my 2nd form
just like the main datagrid?
Regards
Stephan Steiner