我在一个类中有以下方法:
public IPlayerInfo GetPlayerInfo(int playerId)
{
return GetPlayerDetails(playerId).Matches; // Matches have Runs and Wickets list
}
我有一个课程如下:
public class MyClass
{
public Lazy<IMyInterface> _service1;
public MyClass(Lazy<IMyInterface> service1)
{
_serivce1 = service1;
}
public void SomeMethod()
{
var runsList = _serivce1.GetPlayerInfo(1).Runs; // debugging this line of code
}
}
当我尝试调试上面的代码时,
我看到了_serivce1.GetPlayerInfo(1)使用 quick watch ( Shift + F9)的价值。我扩展了它的所有子节点。它的子节点之一是Runs。我扩展了Runs。它显示Expanding the Results View will enumerate the IEnumerable。我一一列举。它是空的。
我没有关闭调试
一段时间后,当我按下 shift + F9 并在 quick watch 中再次查看它时,它在我枚举 IEnumerable 后添加了一项。魔法!
一段时间后,当我按下 shift + F9 并在 quick watch 中再次查看它时,它在我枚举 IEnumerable 后添加了第二个项目。魔方!!
然后,由于_serivce1.GetPlayerInfo(1).Runs添加了两个项目,而不是加载_serivce1.GetPlayerInfo(1)和扩展子节点Runs,我尝试_serivce1.GetPlayerInfo(1).Runs直接调试但它是空的 :(
当我在没有调试的情况下运行时,_serivce1.GetPlayerInfo(1).Runs(因此runsList)根本没有项目。如果这是由于延迟执行,请告诉我。另外,请让我知道此问题的解决方案。
收到一只叮咚
随时随地看视频慕课网APP
相关分类