If you retrieve an instance variable within a static method based on a parameter supplied to the static method, is it possible the instance variable can get stepped on if the static method is called at exactly the same time by different callers? The method I am calling is defined below and I am wondering if the instance variable invoice can be corrupted... any clarification would be greatly appreciated!
public static void SendInvoiceReceipt(int invoiceId, string recipientEmailAddress)
{
var invoice = ObjectFactory.GetInvoiceDAL().GetInvoiceByInvoiceId(invoiceId);
var htmlBody = BuildHtmlInvoiceReceipt(invoice);
var txtBody = BuildTextInvoiceReceipt(invoice);
UtilitiesManager.Emails.EmailUtil.Send(SiteConfigUtilities.GetSMTPServer(),
"referral@realtors.net", recipientEmailAddress, String.Empty,
"Pay开发者_JAVA技巧ment Receipt", htmlBody, txtBody);
}
invoice
is a local variable (not an "instance variable"). It is allocated on the stack, and each thread has its own stack. There is no way for another thread to affect it.
精彩评论