The function evaluation requires all threads to run - MVC

丶灬走出姿态 提交于 2020-07-15 05:14:30

问题


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

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.


回答1:


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.




回答2:


It is because it needs to run the code to show you the result in the debugger. You can press the icon at the right to evaulate it, or you can go to Options -> Debugging and turn off "Enable property evaluation or other implicit function calls".



来源:https://stackoverflow.com/questions/34288814/the-function-evaluation-requires-all-threads-to-run-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!