I have a program that at one point launches a task where a series of actions are executed, while those actions are in a loop checking until that task ends or a certain date is reached. What I want is to debug only what happens in that task, specifically in the sendsCompleted() code. Currently I am randomly jumping between the loop code and the task itself. I am attaching the code to see if someone 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);
}
Thanks.
You can tell the debugger to only break a specific thread, in this case the one created by ´StartNew()´
enviosCompletados
ThreadId = xxx
where xxx is the number of the thread.In addition, for it to work correctly you must deactivate the other breakpoints