delegate question!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.



Relevant Pages

  • BUG?! Visual Studio .NET 2003: Why is a Modal Dialog destroyed?
    ... which is to minimize a WinForm Application with an Open Modal ... Timer timer = new Timer; ... private void btShowModal_Click(object sender, EventArgs e) ...
    (microsoft.public.dotnet.framework)
  • BUG?! Visual Studio .NET 2003: Why is a Modal Dialog destroyed?
    ... which is to minimize a WinForm Application with an Open Modal ... Timer timer = new Timer; ... private void btShowModal_Click(object sender, EventArgs e) ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: pass "out" parameter to ShowDialog?
    ... public partial class MainForm: Form ... private void button1_Click ... WinForm wf = new WinForm; ... public string SomePublicString ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Drag and Drop
    ... Well that seems to be just for Web forms, I'm in a winform.. ... private void FormDownload_DragEnter ... How would I go about grabbing that as well? ...
    (microsoft.public.dotnet.languages.csharp)