Performance related issue regarding times like 00:00:00:000
<p>I have <a href="http://spunit.tk/x/Untitled-1.png" rel="nofollow">this ListView</a>. My goal is to add / subtract a fixed time to all the times / selected times in the list. The thing is that there will be somewhat around 1000-3000 rows in it, so it takes some time. My goal is to make this as fast for the computer as possible.</p>

<p>Right now if I spam-run the function, it takes some time for the form to finish, and if I chose to do it with selected rows, half of them, then the form freezes for a while before finishing.</p>

<p>My code right now looks like this (<a href="http://spunit.tk/x/564654.png" rel="nofollow">here's a picture of the code for better view</a>):</p>

<pre><code>    public void PlusMinus(bool plus)
    {
        int items_to_set = 0;
        int msec_start = 0;
        int msec_end = 0;
        int msec_box = Convert.ToInt32(mskTime.Text.Substring(9, 3)) +
        (Convert.ToInt32(mskTime.Text.Substring(6, 2)) * 1000) +
        (Convert.ToInt32(mskTime.Text.Substring(3, 2)) * 60000) +
        (Convert.ToInt32(mskTime.Text.Substring(0, 2)) * 3600000);
        if (rbtnAll.Checked) { items_to_set = listSub.Items.Count; }
        else { items_to_set = listSub.SelectedItems.Count; }


        if (rbtnAll.Checked)
        {
            for (int i = 0; i &lt; items_to_set; i++)
            {
                msec_start = Convert.ToInt32(listSub.Items[i].SubItems[1].Text.Substring(9, 3)) +
                (Convert.ToInt32(listSub.Items[i].SubItems[1].Text.Substring(6, 2)) * 1000) +
                (Convert.ToInt32(listSub.Items[i].SubItems[1].Text.Substring(3, 2)) * 60000) +
                (Convert.ToInt32(listSub.Items[i].SubItems[1].Text.Substring(0, 2)) * 3600000);
                msec_end = Convert.ToInt32(listSub.Items[i].SubItems[2].Text.Substring(9, 3)) +
                (Convert.ToInt32(listSub.Items[i].SubItems[2].Text.Substring(6, 2)) * 1000) +
                (Convert.ToInt32(listSub.Items[i].SubItems[2].Text.Substring(3, 2)) * 60000) +
                (Convert.ToInt32(listSub.Items[i].SubItems[2].Text.Substring(0, 2)) * 3600000);

                if (plus == true) { msec_start += msec_box; msec_end += msec_box; }
                else { msec_start -= msec_box; msec_end -= msec_box; }
                TimeSpan ts = TimeSpan.FromMilliseconds(msec_start);
                listSub.Items[i].SubItems[1].Text = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                ts = TimeSpan.FromMilliseconds(msec_end);
                listSub.Items[i].SubItems[2].Text = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
            }
        }
        else
        {
            for (int i = 0; i &lt; items_to_set; i++)
            {
                msec_start = Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[1].Text.Substring(9, 3)) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[1].Text.Substring(6, 2)) * 1000) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[1].Text.Substring(3, 2)) * 60000) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[1].Text.Substring(0, 2)) * 3600000);
                msec_end = Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[2].Text.Substring(9, 3)) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[2].Text.Substring(6, 2)) * 1000) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[2].Text.Substring(3, 2)) * 60000) +
                (Convert.ToInt32(listSub.Items[listSub.SelectedIndices[i]].SubItems[2].Text.Substring(0, 2)) * 3600000);

                if (plus == true) { msec_start += msec_box; msec_end += msec_box; }
                else { msec_start -= msec_box; msec_end -= msec_box; }
                TimeSpan ts = TimeSpan.FromMilliseconds(msec_start);
                listSub.Items[listSub.SelectedIndices[i]].SubItems[1].Text = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                ts = TimeSpan.FromMilliseconds(msec_end);
                listSub.Items[listSub.SelectedIndices[i]].SubItems[2].Text = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D3}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
            }
        }
    }
</code></pre>

<p>So is there some changes I could make that would be a somewhat big positive impact on the performance here?</p>
