Problem debugging a thread when there are several assets Visual Studio 2015

2

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.

    
asked by U. Busto 19.07.2017 в 17:12
source

1 answer

1

You can tell the debugger to only break on a specific thread in this case the one created by the STARTNew () '

  • Open the Breakpoints window ( Ctrl + Alt + B )
  • Right click on a breakpoint that is within enviosCompletados
  • Settings ...
  • Activates Conditions
  • Choose Filter
  • In the expression you can put ThreadId = xxx where xxx is the number of the thread.
  • Also, to work correctly you must deactivate the other breakpoints

        
    answered by 19.07.2017 / 17:24
    source