I have a program that reaches a point and launches a task where a series of actions are executed, while those actions I am in a loop checking until that task ends or a certain date is reached. What I want is to purge only what happens in that task, specifically in the code Completed shipping () Currently I jump randomly between the loop code and the task itself. I attached the code to see if anyone can help me:
Thread thread = null;
Task t = Task.Factory.StartNew(() =>
{
thread = Thread.CurrentThread;
enviosCompletados();
});
DateTime fin = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second).AddMinutes(minutosProceso);
while (!t.IsCompleted && (DateTime.Now < fin))
{
Thread.Sleep(300);
}
Thank you.