所以我有一个奇怪的错误,我希望有人可以帮助我。
我有以下代码从WCF RIA服务中获取一些实体,这是在Silverlight 4中,尽管我的猜测是没有区别的。
我错过了什么?
public class MyModel
{
...
public IEnumerable<MyEntity> Result { get; private set; }
public void Execute()
{
Context.Load(Query, LoadBehavior.RefreshCurrent, o =>
{
if (o.HasError)
{
ExecuteException = o.Error;
if (ExecuteError != null)
ExecuteError(this, EventArgs.Empty);
o.MarkErrorAsHandled();
}
else
{
//I've stepped through the code and the assignment is working
//Result != null
Result = o.Entities;
if (ExecuteSuccess != null)
ExecuteSuccess(this, EventArgs.Empty);
//Inside any Handler of ExecuteSuccess
//MyModel.Result == null
//However I set a break point after ExecuteSuccess is triggered,
//and once again MyModel.Result != null
}
if (ExecuteComplete != null)
ExecuteComplete(this, EventArgs.Empty);
ExecuteBusy = false;
}, false);
}
}
一切正常,直到我达到这一点:
MyModel.ExecuteSuccess += (o,e) => {
//At this point MyModel.Result == null. but why?
var result = MyModel.Result;
};
答案 0 :(得分:0)