Hello,
I have these tasks just to call the methods and make the program faster. Those methods work perfectly when they are called out of the Task. They add different overlays to my display images (I have 5 displays). I have just added some console.writelines to check where the program stops working.
Task task1 = Task.Run(() =>
{
Console.WriteLine("Pre Task1");
LeftCamera();
Console.WriteLine("Task1");
});
Task task2 = Task.Run(() => { Console.WriteLine("Pre Task2"); RightCamera(); Console.WriteLine("Task2"); });
Task.WaitAll(task1, task2);
Task task5 = Task.Run(() => { Console.WriteLine("Pre Task5"); ChimneyHeightCalc(); Console.WriteLine("Task5"); });
Task task6 = Task.Run(() => { Console.WriteLine("Pre Task6"); ThreadWidthCalc(); Console.WriteLine("Task6"); });
Task.WaitAll(task5, task6);
Task task3 = Task.Run(() => { Console.WriteLine("Pre Task3"); BoreEdgeAndLabel(); Console.WriteLine("Task3"); });
Task task4 = Task.Run(() => { Console.WriteLine("Pre Task4"); CompleteHandle(); Console.WriteLine("Task4"); });
Console.WriteLine("Task methods DONE!");
Console.WriteLine(watch.ElapsedMilliseconds);
watch.Stop();
watch.Reset();
The program just stops working (hang up) when any of the methods is going to add an overlay, for example here:
if (ChkCrossHairs.Checked)
{
Console.WriteLine("LC 5970");
Display1.Overlays.Add(new CrossHairOverlay("", false, Color.WhiteSmoke, false, new Point(Display1.Image.Width / 2, Display1.Image.Height / 2), new Size(Display1.Image.Width, Display1.Image.Height)));
}
Do you have any idea of what is going on here?
Thank you!