How to avoid the class rewritten in multi thread processing?
<p>I wrote this code in order to use parallel processing:</p>

<pre><code>var charge = new Charge[Job.Jobs.Length];
for (int i = 0; i &lt; Job.Jobs.Length; i++)
{
    charge[i] = new Charge
    {
        ID = Convert.ToInt64(Job.Jobs[i].Parameters),
        Job = new SystemJob { ID = Job.Jobs[i].ID, Type = Job.Type },
    };
    var status = charge[i].GetSubscribeInformation();
    if (status == false)
        continue;

    Task.Run(() =&gt; charge[i].Subscribe());
    //before task runs, the i value changes and causes error.
}
</code></pre>

<p>The problem is before <code>Task.Run(() =&gt; charge[i].Subscribe());</code> execution the <code>i</code> value changes and causes error. How can I avoid this?<br>
I can wait until after <code>Task.Run()</code> but it doesn't seem like a good idea. What choices do I have?</p>