Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SmtpMail timeout

SmtpMail timeout

Scheduled Pinned Locked Moved C#
helpcsharpperformancetutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hkulten
    wrote on last edited by
    #1

    Hi all! Here is my problem: I am developing a Windows service written in C#. The work of this service is to send an alert by mail when the total memory of the OS is too high for example. I'm using the System.Web.Mail namespace to send a mail and everything is ok. I put this piece of code in a thread to make my application more reliable, like that: ' the code for sending mail is in the ThreadLoop method of the Job class Thread jobThread = new Thread(new ThreadStart(current_job.ThreadLoop)); jobThread.Start(); ' wait until the job is done or the timeout is reached bool noTimeout = current_job.Mre.WaitOne(30*1000, false); ' stop the thread... jobThread.Abort(); Ok. My problem occured when there is a big file attached to the mail, and the timeout is reached. The method Abort() does not quit the thread until the entire mail is sent... And I cannot add a timeout to the System.Web.Mail.SmtpMail.Send method, then I am stuck. :confused: Is there a way to force the termination of a thread? Thanks. ;)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups