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".
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
Thanks. This component is already a great option. A good thing to include for next versiones.
Hi,
I have the same problem.
What can I do to resolve this problem?
Very good component!
Thanks