Menu

Error when using smtp.send in a thread pool

Help
DDAY
2004-09-03
2013-04-15
  • DDAY

    DDAY - 2004-09-03

    Hi. When creating threads in a pool that use smtp.send I get an error after calling the method for a certain number of times. Sometimes it tells me that there is no reference to the smtp object or that it does not have access to the "System.Net.Sockets.Socket".

    I'm using sonehting like this...

    while(datareader.Read())
    {                .
    ThreadPool.QueueUserWorkItem(new WaitCallback(smtp.send),new State(datareader[0].ToString()));
    }

    thanks.

     
    • Stephen

      Stephen - 2004-09-03

      What your code do is queue smtp.Send() calls into the thread pool. Wich means that the Send method of the *same* instance of the Smtp class will be invoked by multiple threads at the same time. As far as I can tell from looking at the source, the whole Smtp class is not thread-safe, so you have to expect an erratic behavior.

       
    • DDAY

      DDAY - 2004-09-03

      Thanks. This component is already a great option. A good thing to include for next versiones.

       
    • gianluigi

      gianluigi - 2005-02-20

      Hi,

      I have the same problem.

      What can I do to resolve this problem?

      Very good component!

      Thanks

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.