G
Guest
Hi,
* Apologies for reposting this from .NET Academic *
I am having problems updatingh the user interface in a multi-threaded
application.
BACKGROUND
My App has a user interface (the starting class containing main) and a
CPU class to handle many asynchronous comms routines.
The user interface will be kept updated on the status of the comms by the
CPU class.
My user interface creates an instance of a class called CPU and passes itself
in the constructor this way the CPU can update the user interface by calling
a method of UI
PROBLEM
The user interface is becoming unresponsvie.
The cursor turns to the hour glass and it doesnt repaint
Although all the comms threads run happily in the background as soon as
the CPU tries to call the UpdateScreen method the UI hangs.
ASSISTANCE REQUIRED
Could you please advise me on how i should go about resolving such a problem.
I may well be using bad coding strtegy so pleas advise as you see fit on any
aspect.
Thanks,
Shaun
PSEUDO CODE
// within the UI class
private CPU theCPU;
public UI()
{
theCPU = new CPU(this);
}
UpdateScreen(string status)
{
textBox1.Text = status;
panel1.Visible= ! panel1.Visible;
}
// within the CPU class
public CPU (UI userInterface)
{
this.userInterface = userInterface;
// start threads to run async comms
}
private void ReceivedStatusChange()
{
userInterface.UpdateScreen("Some new status info");
}
* Apologies for reposting this from .NET Academic *
I am having problems updatingh the user interface in a multi-threaded
application.
BACKGROUND
My App has a user interface (the starting class containing main) and a
CPU class to handle many asynchronous comms routines.
The user interface will be kept updated on the status of the comms by the
CPU class.
My user interface creates an instance of a class called CPU and passes itself
in the constructor this way the CPU can update the user interface by calling
a method of UI
PROBLEM
The user interface is becoming unresponsvie.
The cursor turns to the hour glass and it doesnt repaint
Although all the comms threads run happily in the background as soon as
the CPU tries to call the UpdateScreen method the UI hangs.
ASSISTANCE REQUIRED
Could you please advise me on how i should go about resolving such a problem.
I may well be using bad coding strtegy so pleas advise as you see fit on any
aspect.
Thanks,
Shaun
PSEUDO CODE
// within the UI class
private CPU theCPU;
public UI()
{
theCPU = new CPU(this);
}
UpdateScreen(string status)
{
textBox1.Text = status;
panel1.Visible= ! panel1.Visible;
}
// within the CPU class
public CPU (UI userInterface)
{
this.userInterface = userInterface;
// start threads to run async comms
}
private void ReceivedStatusChange()
{
userInterface.UpdateScreen("Some new status info");
}