I'm new to c# async await mechanism. I have checked all the previous examples of async, await but none of them is exactly like mine. what I would like to do? I have a foreach loop and I would like to stop it on a certain rule, do some stuff and continue running by clicking on a button. Here is simple code example:
private void RunConvert() // START
{
foreach (PartSettings File in PartsFromXLS) // RUNING THE FOREACH LOOP ON A LIST
{
ProcessSinglePart(PathStep, PathMCX);
}
}
public static async void ProcessSinglePart(string PartPathToRead, string PartPathToSave)
{
// DO SOME STUFF BEFORE THE CHECK
if (PartLength < PartWidth) // SOME CHECK VALUES
{
await WhenClicked(); //HERE I WOULD LIKE TO WAIT FOR BUTTON CLICK
}
//DO SOME STUFF AFTER THE CHECK
}
private void GeometryOK_Click(object sender, EventArgs e)
{
// I WOULD LIKE TO WAIT FOR THIS CLICK
}