Problem:
I'm currently calling 3 functions inside my code, which are executed behind each other which would take some time to finish. So I was wondering if there is a way to call them at the same time, for example using a Parallel.For loop.
In case I could use a Parallel.For loop, how would I manage to do this? Would this be the right way to use it?
Parallel.For(0, 1, i =>
{
bool check1 = function1(address);
bool check2 = function2(address);
bool check3 = function3(address);
});
My current code:
private void check()
{
for (int i = 0; i < dataGridView1.RowCount; i++)
{
string address = dataGridView1.Rows[i].Cells[0].Value.ToString();
try
{
if (address.Length < 6)
{
// Those 3 functions are currently called behind each other
// Could those be called inside a Parallel.For loop at the same time?
bool check1 = function1(address);
bool check2 = function2(address);
bool check3 = function3(address);
}
else
{
dataGridView1.Rows[i].Cells[2].Value = "Error";
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}