Wednesday

accessed from a thread other than the thread it was created on.

This happends when you are trying to modify control from another thread.You cannot do this directly it could be done only by invoker.
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:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...