Multithreaded GridView updates
<p>Here, I am using simple logic in C#. I am subtracting days from two <code>DateTimePicker</code>s and generating the same number of <code>GridView</code> rows as total days. I put this logic in a <code>Timer</code>, which ticks at an interval of 100 milliseconds and executes automatically. This works fine for 90-100 rows, but if it goes to 1000 rows, then the program gets stuck. So, I am thinking I need to use threads. How can I do this? I know basic multithreading, and tried this, which didn't work:</p>

<pre><code>private void timer1_Tick(object sender, EventArgs e)
{
    myMethod();
}

void myMethod() {
    ed_Picker.MinDate = sd_Picker.Value;
    TimeSpan ts = new TimeSpan();

    //GridView.Rows.cont

    label3.Text = ed_Picker.Value.CompareTo(sd_Picker.Value).ToString();
    //dateTimePicker2.MinDate = dateTimePicker1.Value;

    ts = ed_Picker.Value.Subtract(sd_Picker.Value);
    double d;

    d = Math.Ceiling(ts.TotalDays) + 1;
    label3.Text = d.ToString();
    DataGridViewRow row = new DataGridViewRow();


    GridView.RowCount = Int32.Parse(d.ToString()); // This is key line which I like to put in new Thread
    for (int i = 1; i &lt;= GridView.RowCount; i++)
    {
        GridView.Rows[i - 1].Cells[0].Value = sd_Picker.Value.AddDays(Convert.ToDouble(i - 1)).ToLongDateString();
        GridView.Rows[i - 1].Cells[0].ReadOnly = true;
    }
    DateTimeConverter dtc = new DateTimeConverter();
    TimeSpan ts1 = new TimeSpan();

    try
    {
        for (int i = 0; i &lt; GridView.RowCount; i++)
        {
            ts1 += Convert.ToDateTime(GridView.Rows[i].Cells[2].Value).Subtract(Convert.ToDateTime(GridView.Rows[i].Cells[1].Value));
        }
    }
    catch (Exception ex)
    {

    }

    label6.Text = ts1.ToString();
}
</code></pre>
