本文整理汇总了C#中LoadOperation.Cancel方法的典型用法代码示例。如果您正苦于以下问题:C# LoadOperation.Cancel方法的具体用法?C# LoadOperation.Cancel怎么用?C# LoadOperation.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadOperation
的用法示例。
在下文中一共展示了LoadOperation.Cancel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exceptions
public void Exceptions()
{
Cities.CityDomainContext cities = new CityDomainContext(TestURIs.Cities);
Action<LoadOperation<City>> loCallback = (op) =>
{
if (op.HasError)
{
op.MarkErrorAsHandled();
}
throw new InvalidOperationException("Fnord!");
};
Action<SubmitOperation> soCallback = (op) =>
{
if (op.HasError)
{
op.MarkErrorAsHandled();
}
throw new InvalidOperationException("Fnord!");
};
Action<InvokeOperation> ioCallback = (op) =>
{
if (op.HasError)
{
op.MarkErrorAsHandled();
}
throw new InvalidOperationException("Fnord!");
};
LoadOperation lo = new LoadOperation<City>(cities.GetCitiesQuery(), LoadBehavior.MergeIntoCurrent, loCallback, null, loCallback);
// verify completion callbacks that throw
ExceptionHelper.ExpectInvalidOperationException(delegate
{
try
{
lo.Complete(DomainClientResult.CreateQueryResult(new Entity[0], new Entity[0], 0, new ValidationResult[0]));
}
catch (Exception ex)
{
Assert.IsTrue(ex.StackTrace.Contains("at OpenRiaServices.DomainServices.Client.Test.OperationTests"), "Stacktrace not preserved.");
throw;
}
}, "Fnord!");
// verify cancellation callbacks for all fx operation types
lo = new LoadOperation<City>(cities.GetCitiesQuery(), LoadBehavior.MergeIntoCurrent, null, null, loCallback);
ExceptionHelper.ExpectInvalidOperationException(delegate
{
lo.Cancel();
}, "Fnord!");
SubmitOperation so = new SubmitOperation(cities.EntityContainer.GetChanges(), soCallback, null, soCallback);
ExceptionHelper.ExpectInvalidOperationException(delegate
{
so.Cancel();
}, "Fnord!");
InvokeOperation io = new InvokeOperation("Fnord", null, null, null, ioCallback);
ExceptionHelper.ExpectInvalidOperationException(delegate
{
io.Cancel();
}, "Fnord!");
}