IdeaBlade DevForce 2010 Help Reference
Fail Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class : Fail Method



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
Used to force a failed or cancelled return from within a Coroutine iterator.

Syntax

Visual Basic (Declaration) 
Public Shared Function Fail( _
   ByVal error As Exception, _
   Optional ByVal isErrorHandled As Boolean, _
   Optional ByVal cancelled As Boolean _
) As CoroutineOperation
Visual Basic (Usage)Copy Code
Dim error As Exception
Dim isErrorHandled As Boolean
Dim cancelled As Boolean
Dim value As CoroutineOperation
 
value = Coroutine.Fail(error, isErrorHandled, cancelled)
C# 
public static CoroutineOperation Fail( 
   Exception error,
   bool isErrorHandled,
   bool cancelled
)
C++/CLI 
public:
static CoroutineOperation^ Fail( 
   Exception^ error,
   bool isErrorHandled,
   bool cancelled
) 

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

Use Fail within an iterator to force an exit from further processing within the iterator. The completion handler will receive indication of the error or cancellation.

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

© 2013 All Rights Reserved.