Scenario:
I have a windows form that holds a DataGridWiew
with 3 pre-defined columns.
I have 3 variables declared outside the function and assigned to inside the function.
I have a function that enumerates stuff and puts it in the 3 columns, line by line:
string VARIABLE1;
string VARIABLE2;
string VARIABLE3;
private void FunctionEnumerateStuff()
{
foreach (StuffObject STUFF in StuffCollection)
{
VARIABLE1 = STUFF.SubStuff1.ToString();
VARIABLE2 = STUFF.SubStuff2.ToString();
VARIABLE3 = STUFF.SubStuff3.ToString();
DatagridWiew1.Rows.Add(VALUE1, VALUE2, VALUE3);
}
}
What I want to do, is to execute this function from a BackGroundWorker
process, so that the GUI of the application will be smooth and responsive.
I have read up on backgroundworkers but I am having trouble relating, because all examples seems to be of entirely different scenarios and most of them are overwhelmingly complex.
Can some helpful pedagogic soul help me and others with a very basic example of how to get this to work in the simplest way possible. Thanks.