This is a huge jump for thread implementation, now it is become very easy to use thread without any headache. Just write your code snippet inside Thread lambda no need to create a function and point that function to thread.
Example:
public void MailSend(string from, string to, string bcc, string cc, string subject, string body)
{
new Thread(() =>
{
MailMessage mMailmsg = new MailMessage();
mMailmsg.From ="jjj@gmail.com";
char[] tosplitter = { ';' };
string[] tos = to.Split(tosplitter);
foreach (string d in tos)
{
mMailmsg.To.Add(new MailAddress(d));
}
try
{
if ((bcc != null) && (bcc != string.Empty))
{
char[] bccsplitter = { ';' };
string[] bccs = bcc.Split(bccsplitter);
foreach (string d in bccs)
{
mMailmsg.Bcc.Add(new MailAddress(d));
}
}
}
catch (Exception exp)
{
string str = exp.Message.ToString();
throw exp;
}
try
{
if ((cc != null) && (cc != string.Empty))
{
//Spliting to cc
char[] ccsplitter = { ';' };
string[] ccs = cc.Split(ccsplitter);
foreach (string ds in ccs)
{
mMailmsg.CC.Add(new MailAddress(ds));
}
}
}
catch (Exception exp)
{
string str = exp.Message.ToString();
throw exp;
}
mMailmsg.Subject = subject;
mMailmsg.Body = body;
mMailmsg.IsBodyHtml = true;
mMailmsg.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mSmtpClient.Send(mMailmsg);
}).Start();
}