C# Parallel.Foreach, New Class and Static voids./strings
<p>I'm using a <code>Parallel.ForEach</code> to call and create a new class.</p>

<pre><code>Parallel.ForEach(urlTable.AsEnumerable(),drow =&gt;
        {
            using (var WCC = new MasterCrawlerClass() )
            {
                WCC.MasterCrawlBegin(drow);
            }
        });
</code></pre>

<p><code>MasterCrawlerClass</code> contains <code>private static voids</code> and <code>private static string</code>.  I guess my question is this.  Since I am calling a new class in my <code>foreach</code>, are all my <code>voids</code>/<code>strings</code> in that new class instance safe?</p>

<pre><code>class MasterCrawlerClass : IDisposable
{
    public void Dispose()
    {
        GC.Collect();
    }
    public static void SetNewProxy()
    {
        string mysql_Proxyserver_ProxyPort = "select ProxyServer,ProxyPort,ResponseTime FROM proxies.tblproxies where Active = 1 and DateTested &gt;= Date_sub(CurDate(),INTERVAL 2 day) and ResponseTime &lt;= 3 order by Rand() limit 1";
        DataTable proxyDT = new DataTable();
        proxyDT = DTTable(mysql_Proxyserver_ProxyPort, "mysql_Proxyserver_ProxyPort");
        ProxyServer = proxyDT.Rows[0].ItemArray[0].ToString();
        ProxyPort = Convert.ToInt32(proxyDT.Rows[0].ItemArray[1].ToString());
    }

    private static string HTMLModelProcess(string inputString)
    {
        string returnString = string.Empty;
        string ModelString = inputString.Replace("Certified", "").Replace("Used", "").Trim();
        string[] makeModelSplit = ModelString.Split(new char[] { ' ' }, 4);
        returnString = makeModelSplit[2];
        return returnString;

    }
    private static string ProxyServer { get; set; }
    private static int ProxyPort { get; set; }

}

private static DataTable DTTable(string mysqlQuery, string queryName)
    {
        DataTable DTTableTable = new DataTable();
        try
        {
            MySqlDataAdapter DataDTTables = new MySqlDataAdapter(mysqlQuery, MySQLProcessing.MySQLStatic.Connection);
            DataTable DataDTTablesDT = new DataTable();
            DataDTTables.SelectCommand.CommandTimeout = 240000;
            DataDTTables.Fill(DataDTTablesDT);
            DTTableTable = DataDTTablesDT;

        }
        catch (Exception ex)
        {

            GenericLogging("Failed MySQLquery: " + ex.Message.ToString(), "MySQLProcessor", "DTTable", "", "MysqlError", "", queryName, mysqlQuery);

        }
        return DTTableTable;
    }
</code></pre>

<p>The MysqlProcessing.Mysqlstatic.Connection is set before the Parallel and should NEVER change.</p>

<p>This is a few more <code>voids</code> and some more <code>strings</code>.  I dont understand Threading completely yet, so I'm trying to work my way through it.</p>
