Hi Aung,
You may need to pass the a reference to the form instance or the
label instance in 'MyUI' to the 'LogicStuff' class.
Alternatively, you can expose events in the 'LogicStuff' class that
is fired when the label needs to be updated. 'MyUI' would then
have to subscribe to these events. When the event is fired,
'MyUI' updates its label.
In the example that you specified, let's assume we adopt the first approach:
class MyUI : Form
{
void PerformBusinessLogic()
{
LogicStuff stuff = new LogicStuff(this);
stuff.DoSomething();
}
void UpdateLabel(String text)
{
lblStatus.Text = text;
}
// ....
}
public class LogicStuff
{
private MyUI _form = null;
public LogicStuff(MyUI form)
{
this._form = form;
}
public void DoSomething()
{
// ....
_form.UpdateLabel("Completed tasks");
}
}
Regards,
Aravind C