Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

C# datagridview backgroundworker update incomplete

$
0
0

my C# main form has many backgroundworker functions and the majority of the backgroundworkers are in the same form class.

I have one backgroundworker calling child class which is pass the backgroundworker object. for the most part it will successfully update the backgroundworker.progresschanged which one step is to update a datagridview (

case 0:
   msg = (string[])e.UserState;
   //tbStatus.Text = msg[0] + " = " + msg[1] + " > " + msg[2];
   dataGridView1.Rows.Add(msg[0], msg[1], msg[2], msg[3]);
   break;

).

as I stated it work for the most part. if loop through three iteration of this backgroundworker thread all but the last iteration will update the datagridview. according to the step through I have done I see the last iteration step through the backgroundworker.progresschange mention above. but it will not display in the datagrid on the form.

        private void backgroundWorker6_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            string[] msg = new string[4];
            switch (e.ProgressPercentage)
            {
                case 0:
                    msg = (string[])e.UserState;
                    //tbStatus.Text = msg[0] + " = " + msg[1] + " > " + msg[2];
                    dataGridView1.Rows.Add(msg[0], msg[1], msg[2], msg[3]);
                    break;
                case 1:
                    tbStatus.Text = (string)e.UserState;
                    break;
                case 2:
                    tBResult.Text = (string)e.UserState;
                    break;
                case 3:
                    string msg1 = "Processing file " + (string)e.UserState + " of " + tBN_Files.Text;
                    label7.Text = msg1;
                    break;
            }
        }//private void backgroundWorker6_ProgressChanged(object sender, ProgressChangedEventArgs e)


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>