D
DBC User
Hi all,
Could someone explain me the following
I have a winform. I call a long process in async model with a callback.
Now that once I get the call back I update a message to the main
winform. Well I got everything to work (based on an example), but I
didn't understand the fullflow. Why do I need to call a delegate to
update the main winform?
//Delegate declaration
delegate void CallDelegate(XmlNode xNode);
//Display information back to main thread
private void CallThread(XmlNode xNode)
{
if (this.Grid1.InvokeRequired == false)
{
DataSet resultDS=null;
DataSet ds = GetData();
ProcessDataandShow();
DisplayComplete();
}
else
{
CallDelegate calMain = new CallDelegate(CallThread);
BeginInvoke(calMain, new object[]{xNode});
}
}
//Callback for long process on completion
private void GetProcComplete(object sender, EventArgs
statusInformation)
{
CallMainThread(statusInformation.XNode);
}
I appriciate if someone can educate me on this?
Thanks in advance.
DBC
Could someone explain me the following
I have a winform. I call a long process in async model with a callback.
Now that once I get the call back I update a message to the main
winform. Well I got everything to work (based on an example), but I
didn't understand the fullflow. Why do I need to call a delegate to
update the main winform?
//Delegate declaration
delegate void CallDelegate(XmlNode xNode);
//Display information back to main thread
private void CallThread(XmlNode xNode)
{
if (this.Grid1.InvokeRequired == false)
{
DataSet resultDS=null;
DataSet ds = GetData();
ProcessDataandShow();
DisplayComplete();
}
else
{
CallDelegate calMain = new CallDelegate(CallThread);
BeginInvoke(calMain, new object[]{xNode});
}
}
//Callback for long process on completion
private void GetProcComplete(object sender, EventArgs
statusInformation)
{
CallMainThread(statusInformation.XNode);
}
I appriciate if someone can educate me on this?
Thanks in advance.
DBC