C# Programming
08-15-2010, 10:30 PM
So, it's been a while since I did any threading and so I thought to review some BackgroundWorkers.
I made a test program and get this exception I cannot explain.
It occurs during the ProgressChanged event when reading a double value.
I'm using an ArrayList as argument where the first value is a double (for accurate progress report) and the second value is a string array.
The exception gets thrown when trying to assign the value of the ArrayList to a local double variable.
Can anyone tell me what went wrong and how I can fix it?private void BW_Text_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
ArrayList arg = (ArrayList)e.UserState;
double progress = (double)arg[0]; //exception gets thrown here
string[] content = (string[])arg[1];
textprogress += progress;
TSL_Text.Text = "Status: Reading..." + String.Format("{0:0.##}", textprogress) + "%";
Fill_ListView(true, content);
}Thanks!
I made a test program and get this exception I cannot explain.
It occurs during the ProgressChanged event when reading a double value.
I'm using an ArrayList as argument where the first value is a double (for accurate progress report) and the second value is a string array.
The exception gets thrown when trying to assign the value of the ArrayList to a local double variable.
Can anyone tell me what went wrong and how I can fix it?private void BW_Text_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
ArrayList arg = (ArrayList)e.UserState;
double progress = (double)arg[0]; //exception gets thrown here
string[] content = (string[])arg[1];
textprogress += progress;
TSL_Text.Text = "Status: Reading..." + String.Format("{0:0.##}", textprogress) + "%";
Fill_ListView(true, content);
}Thanks!