By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

SmtpMail - not multithread friendly?

P: n/a
The SmtpMail class has a static property to set the server and a static
method to send an email. But if its static, how can it work in a
multithreaded environment? Surely one would want to create an instance of
the server and invoke the send() method?
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
there are some commercial components that may provide better capability for
multithreaded sending.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl...
The SmtpMail class has a static property to set the server and a static
method to send an email. But if its static, how can it work in a
multithreaded environment? Surely one would want to create an instance of
the server and invoke the send() method?

Jul 21 '05 #2

P: n/a
My code will be running inside a server (BizTalk server). I don't have
control over the number of threads, BizTalk manages this. Therefore, would
you say that using SmtpMail is unsafe in an environment like this? Should I
wrap all use of SmtpMail within a static synchronized method?

I can envisage a scenario where one thread changes the smtp server property,
is just about to call send message, when another thread that it knows
nothing about updates the smtp server property to something else.

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:1m_td.468943$wV.356468@attbi_s54...
there are some commercial components that may provide better capability for multithreaded sending.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl...
The SmtpMail class has a static property to set the server and a static
method to send an email. But if its static, how can it work in a
multithreaded environment? Surely one would want to create an instance of the server and invoke the send() method?


Jul 21 '05 #3

P: n/a
Actually, what I would recommend is that you purchase, for less than $300, a
license for a commercially available SMTP component that is multi-thread
ready, rather than adding a bottleneck that will undoubtably cost you
considerable performance in a biztalk environment.

Performance hits in biztalk are very difficult to diagnose, and may of my
past clients have gone so far as adding expensive hardware as a "test" to
see if Biztalk performance would improve.

Given the potential for future expense due to a design flaw in a small
corner of .net, why not spend a small amount of money, right now, for a
component that doesn't have the flaw?

Otherwise, for the hope to save $300, you could slow down a system that
costs thousands, and incur the liklihood that additional thousands will be
spent trying to shore it up.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl...
My code will be running inside a server (BizTalk server). I don't have
control over the number of threads, BizTalk manages this. Therefore, would
you say that using SmtpMail is unsafe in an environment like this? Should I wrap all use of SmtpMail within a static synchronized method?

I can envisage a scenario where one thread changes the smtp server property, is just about to call send message, when another thread that it knows
nothing about updates the smtp server property to something else.

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:1m_td.468943$wV.356468@attbi_s54...
there are some commercial components that may provide better capability

for
multithreaded sending.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl...
The SmtpMail class has a static property to set the server and a static method to send an email. But if its static, how can it work in a
multithreaded environment? Surely one would want to create an instance of the server and invoke the send() method?



Jul 21 '05 #4

P: n/a
Very sound advice, thanks Nick. As you state, it is a bit of a design flaw
in the framework - unusual though that they should have done it that way.

Thanks again.

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:Iajud.547646$D%.137565@attbi_s51...
Actually, what I would recommend is that you purchase, for less than $300, a license for a commercially available SMTP component that is multi-thread
ready, rather than adding a bottleneck that will undoubtably cost you
considerable performance in a biztalk environment.

Performance hits in biztalk are very difficult to diagnose, and may of my
past clients have gone so far as adding expensive hardware as a "test" to
see if Biztalk performance would improve.

Given the potential for future expense due to a design flaw in a small
corner of .net, why not spend a small amount of money, right now, for a
component that doesn't have the flaw?

Otherwise, for the hope to save $300, you could slow down a system that
costs thousands, and incur the liklihood that additional thousands will be
spent trying to shore it up.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:e6**************@TK2MSFTNGP12.phx.gbl...
My code will be running inside a server (BizTalk server). I don't have
control over the number of threads, BizTalk manages this. Therefore, would
you say that using SmtpMail is unsafe in an environment like this? Should
I
wrap all use of SmtpMail within a static synchronized method?

I can envisage a scenario where one thread changes the smtp server

property,
is just about to call send message, when another thread that it knows
nothing about updates the smtp server property to something else.

"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:1m_td.468943$wV.356468@attbi_s54...
there are some commercial components that may provide better

capability for
multithreaded sending.

--- Nick

"Xerox" <an**@anon.com> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl...
> The SmtpMail class has a static property to set the server and a static > method to send an email. But if its static, how can it work in a
> multithreaded environment? Surely one would want to create an

instance of
> the server and invoke the send() method?
>
>



Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.