In order to resolve this situation please do following:
step 1: Create following extension
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
public static class Extension
{
public static void InvokeIfRequired(this Control control, MethodInvoker action)
{
if (control.InvokeRequired)
{
control.Invoke(action);
}
else
{
action();
}
}
}
step2.Using developed extension:
Now in other thread instead of calling control directly like :
htmlPanel1.Text = resml;
You have to call it as follows:
htmlPanel1.InvokeIfRequired(() =>{ htmlPanel1.Text = resml; });
No comments:
Post a Comment