New Posts New Posts RSS Feed: SaveChangesAsync never returns
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

SaveChangesAsync never returns

 Post Reply Post Reply
Author
RyanBritton View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Oct-2009
Location: South Africa
Posts: 10
Post Options Post Options   Quote RyanBritton Quote  Post ReplyReply Direct Link To This Post Topic: SaveChangesAsync never returns
    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();
            }
        }
-----------------------------------------------------------------------------------------------------------------------------
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post 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!
 
Back to Top
RyanBritton View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Oct-2009
Location: South Africa
Posts: 10
Post Options Post Options   Quote RyanBritton Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
jsobell View Drop Down
Groupie
Groupie
Avatar

Joined: 02-Apr-2009
Location: Australia
Posts: 80
Post Options Post Options   Quote jsobell Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
RyanBritton View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Oct-2009
Location: South Africa
Posts: 10
Post Options Post Options   Quote RyanBritton Quote  Post ReplyReply Direct Link To This Post Posted: 17-May-2010 at 6:18am
it turns out that it was definitely a server-side lock as you guessed....
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2010 at 3:14pm

Good call jsobell.  Thanks for the help!

Back to Top
RyanBritton View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Oct-2009
Location: South Africa
Posts: 10
Post Options Post Options   Quote RyanBritton Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2010 at 11:39pm
yip. thanks dude :)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down