Print Page | Close Window

Async property navigation and Exceptions

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4592
Printed Date: 06-Sep-2025 at 7:22am


Topic: Async property navigation and Exceptions
Posted By: jbiddle61
Subject: Async property navigation and Exceptions
Date Posted: 05-Nov-2013 at 4:26pm
If I enable async property navigation in my EntityManagers (like TempHire), is there anyway to get notified of any exceptions that are thrown?

I have my database access through a web service (n-tier).
I set a breakpoint just before the access of the navigation property.
When the breakpoint is hit, I stop the web service, and let the program continue.
My PendingEntityResolved event handler never gets called (as expected), but there does not seem to be an exception raised either.

Is there anyway to detect database errors when using async property navigation?



Replies:
Posted By: kimj
Date Posted: 06-Nov-2013 at 10:42am
Unfortunately the Pending*Resolved event args don't contain error information, but you can listen on the EntityManager's Queried and EntityServerError events to receive error information.  If you've also lost connectivity, the ConnectionStateChanged event will fire too.


Posted By: jbiddle61
Date Posted: 07-Nov-2013 at 2:27pm
Thanks, Kimj - that helps some.

So I setup an EntityManagerDelegate to handle these.
So far, so good - if I deliberately cause a database error during async navigation, the event does get passed to my delegate.

The problem I now have is that need some was to determine if I want to handle the error in the delegate or allow it to be passed on.

Basically I need to be able to tell if the exception came from async property navigation or not.
If it comes from async property navigation, I want to handle the error in the delegate; otherwise I want to let the error continue on its merry way and handle it where I am awaiting the async call.

Is there some way to do that?
Or, better yet, is there some way to actually await the async property navigation?



Posted By: kimj
Date Posted: 07-Nov-2013 at 5:49pm
It would be ideal if the pending entity API used the same async/await pattern as other asynchronous methods in DevForce, but we haven't implemented this yet.
 
Right now, although it's ugly, you can check the Query in the EntityQueriedEventArgs - it will be an EntityRelationQuery for any navigation-based query.



Print Page | Close Window