函数评估要求所有线程都运行-MVC [英] The function evaluation requires all threads to run - MVC

查看:124
本文介绍了函数评估要求所有线程都运行-MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将值从模型传递到If语句中的参数时,发生以下错误.

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

这是发生问题的代码,我很确定它不是 ValidateUserPassword 方法.

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);
}

感谢您的帮助.

推荐答案

简短答案:您可以单击右侧的线程"图标来强制评估.

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

长答案: 在调试器中评估方法时,调试器/CLR将当前线程的上下文设置为要评估的方法,设置保护断点,冻结除当前线程以外的所有线程,然后继续执行该过程.遇到断点时,调试器将线程还原到以前的状态,并使用返回值填充窗口.

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.

由于仅一个线程正在运行,因此如果评估线程获得另一个线程已经持有的锁,则有可能创建死锁情况.如果CLR检测到可能的死锁,它将中止评估,调试器最终会显示该消息.

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.

顺便说一句,如果您编写的代码知道在评估后可能会死锁,则可以调用Debugger.NotifyOfCrossThreadDependeny.这将导致您所看到的行为.

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.

这篇关于函数评估要求所有线程都运行-MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆