Friday, July 1, 2011

Threading in C#

Threads are typically created when you want your program to do more that one
thing at once.
In the following example I am using thread to send email as it can

using System.Threading;
private void SendEmail()
 {
        Thread objT1 = new Thread(new ThreadStart(EmailThread));
        objT1.Start();
 }

private void EmailThread()
{
       MailMessage objEmail = new MailMessage();
      objEmail.From = new MailAddress("myNamea@MyCompany.com", "Display Name Here");

      objEmail.To.Add("To@MyCompany.com");
      objEmail.Subject = "put test subject here";

      objEmail.IsBodyHtml = true;

      objEmail.Body = "Email body here";
     SmtpClient objEmailSender = new SmtpClient("MYMailServerName");

    //Send email

    objEmailSender.Send(objEmail);

}

No comments:

Post a Comment

Your project is not referencing the "MonoAndroid,Version=v8.1" framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks" section of your project.json, and then re-run NuGet restore.

I had  the same problem. Reason: file obj/project.assets.json target "MonoAndroid,Version=v7.1" when my project target androi...