新しいスレッドから宣言されたローカル変数の使用法に違いはありますか?
string emailSubject = "New message notification";
string imagePath = somePath;
string conversationName = entity.Name;
new Thread(delegate()
{
foreach (var user in participantList)
{
string newEmailBody = emailBody.Replace("###ImagePath###", imagePath)
.Replace("###UserName###", user.Name)
.Replace("###ConversationName###", conversationName);
MailUtil.SendEmail(user.Email, emailSubject, newEmailBody);
}
}).Start();
それらを新しいスレッドで宣言する方が安全ですか? このような:
new Thread(delegate()
{
string emailSubject = "New message notification";
string imagePath = somePath;
string conversationName = entity.Name;
foreach (var user in participantList)
{
string newEmailBody = emailBody.Replace("###ImagePath###", imagePath)
.Replace("###UserName###", user.Name)
.Replace("###ConversationName###", conversationName);
MailUtil.SendEmail(user.Email, emailSubject, newEmailBody);
}
}).Start();