Class pass by reference and thread
<p>I have code below, I pass <code>attachment</code> object to <code>SendMessage</code> method. The problem is that <code>SendMessage</code> is in another <code>thread</code> and when <code>SendMessage</code> try to use <code>attachment</code> the <code>attachment</code> is already destroyed because Objects is passed as reference by default. What would be best solution for this problem?</p>

<pre><code>var attachment = new Attachment(fileStream, fileName);
new Thread(() =&gt; MailHelper.SendMessage(message.Mail.Headers.From.Address, "EmailConvertSuccess.txt", attachment)).Start();
</code></pre>
