Print Page | Close Window

SaveChangesAsync never returns

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1799
Printed Date: 24-Jan-2020 at 6:25am


Topic: SaveChangesAsync never returns
Posted By: RyanBritton
Subject: SaveChangesAsync never returns
Date Posted: 10-May-2010 at 6:27am
Hi,

I hope that you can assist with a very urgent issue:

In some instances (but not all) our calls to SaveChangesAsync is not returning (ie: a breakpoint on the supplied callback is never hit). Under what conditions will this happen? The only changes that we have made (this was working last week) is a strategy for prepopulating the DevForce cache from the database and persisting the cache to/from a file on startup (so that reference data is not downloaded every time the application runs).

here is an example of where it is failing (Updated is successfully called and the call to SaveChangesAsync completed successfully but Finished is never called):

-----------------------------------------------------------------------------------------------------------------------------
        private void Updated()
        {
            foreach (var parcel in this.Parcels)
            {
                var verifications = parcel.VerifierEngine.Execute(parcel);

                this.ValidationResults.Clear();

                if (!verifications.AreOk)
                {
                    var errors = string.Empty;
                    foreach (var error in verifications.Errors)
                    {
                        errors += error.Description + Environment.NewLine;
                    }

                    MessageBox.Show(errors, "Could not Save", MessageBoxButton.OK);
                    return;
                }
            }

            this.Shipment.Value.GenerateWaybillNumber();

            this.Gateway.EntityManager.SaveChangesAsync(this.Finished, null);
        }

        private void Finished(EntitySavedEventArgs args)
        {
            if (args.Error != null || args.Result == null || !args.Result.Ok)
            {
                throw new Exception("An error occurred while saving the Shipment", args.Error);
            }
            else
            {
                DataNotificationService.UpdateShipments();
                PopupWindowService.ClosePopUp();
            }
        }
-----------------------------------------------------------------------------------------------------------------------------



Replies:
Posted By: ting
Date Posted: 10-May-2010 at 8:02pm
Hi Ryan,
 
Sorry to see that you're having problems.  SaveChangesAsync is designed to always call the callback.  Can you open a support case and submit a test case that shows this?
 
Thanks!
 


Posted By: RyanBritton
Date Posted: 11-May-2010 at 12:54am
We think we've figured this out. We have an asynchronous call in the background which populates 24,000 Geographic records - if we remove this call then the Async operations return, so it seems that the Entity Manager is tied up with this operation (which shouldn't really be the case in an asynchronous scenario). Any comments/ideas as to how to get around this and why it might be occurring? Is there a thread lock in the IdeaBlade architecture which might be causing this bottleneck?


Posted By: jsobell
Date Posted: 16-May-2010 at 3:54pm
Are you trying to save to a table related to the one you're fetching from? If so, the save won't be able to execute at the server end.
Check the Activity Monitor in SQL Server Management Studio and see if your save is locked pending completion of the fetch.
I'd guess that it's far more likely to be a SQL Server side lock than a code one.



Posted By: RyanBritton
Date Posted: 17-May-2010 at 6:18am
it turns out that it was definitely a server-side lock as you guessed....


Posted By: ting
Date Posted: 18-May-2010 at 3:14pm

Good call jsobell.  Thanks for the help!



Posted By: RyanBritton
Date Posted: 18-May-2010 at 11:39pm
yip. thanks dude :)



Print Page | Close Window