views:

43

answers:

1

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(),
            "[email protected]", recipientEmailAddress, String.Empty,
            "Payment Receipt", htmlBody, txtBody);
}
+4  A: 

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.

John Saunders