Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The function evaluation requires all threads to run - MVC

The following error is occuring when passing values from a model to a parameter inside an If Statement.

QuickWatch Error Description

Threads

This is the code the issue is occurring, I'm pretty sure its not the ValidateUserPassword method.

if (PSFNetSystem.ValidateUserPassword(model.Server, model.Username, model.Password) < 0)
{
    ModelState.AddModelError("Password", "Failed to login");
    return View(model);
}

Any help is appreciated, thanks.

like image 473
surGe Avatar asked Dec 15 '15 12:12

surGe


1 Answers

Short answer: You can click on the "thread" icon to the right to force the evaluation.

Long answer: When you evaluate a method in the debugger, the debugger/CLR sets the context of the current thread to the method being evaluated, sets a guard breakpoint, freezes all threads except the current thread, then continues the process. When the breakpoint is hit, the debugger restores the thread to its previous state and uses the return value to populate the window.

Because only one thread is running, it's possible to create deadlock situations if the evaluation thread takes a lock that's already held by another thread. If the CLR detects a possible deadlock it aborts the evaluation and the debugger ultimately shows that message.

Clicking the button to allow all threads to run means that we don't freeze the other threads when retrying the evaluation. This will allow the evaluation to proceed, but has the disadvantage of breakpoints on other threads being ignored.

BTW, If you are writing code that you know will likely deadlock if it's evaluated, you can call Debugger.NotifyOfCrossThreadDependeny. This will cause the behavior you are seeing.

like image 108
Patrick Nelson - MSFT Avatar answered Oct 19 '22 00:10

Patrick Nelson - MSFT