Used to force a failed or cancelled return from within a Coroutine iterator.
Syntax
Parameters
- error
- The exception to return to caller
- isErrorHandled
- If true you will not need to call MarkErrorAsHandled in a completion handler
- cancelled
- Indicates a cancelled operation
Example
C# | Copy Code |
---|
public void SampleCoroutineWithFail() {
var op = Coroutine.Start(CoroutineWithFail);
op.Completed += (s, e) => {
if (e.HasError) {
MessageBox.Show(e.Error.Message);
}
};
}
public IEnumerable<INotifyCompleted> CoroutineWithFail() {
// Do 1 operation
yield return _entityManager.Customers.Take(3).ExecuteAsync();
// Let's fail now, why not?
yield return Coroutine.Fail(new Exception("failed here"), true);
// This operation will never be run because of the fail above.
var op2 = _em1.Areas.Take(2).ExecuteAsync();
} |
Remarks
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also