c# - Sync conflict handling in Azure Mobile Services: ad hoc vs sync handler -
when not using "sync handler", 1 needs catch sync errors push , pull.
push:
samples catch mobileserviceinvalidoperationexception
, mobileservicepushfailedexception
, exception
:
try { await client.synccontext.pushasync(); } catch (mobileserviceinvalidoperationexception ex) { // ...push failed // ...do manual conflict resolution } catch (mobileservicepushfailedexception ex) { // ...push failed // ...do manual conflict resolution } catch (exception ex) { // ...some other failure }
pull:
samples catch mobileserviceinvalidoperationexception
, exception
:
try { await synctable.pullasync("allitems", synctable.createquery()); } catch (mobileserviceinvalidoperationexception ex) { // ...pull failed } catch (exception ex) { // ...some other failure }
sync handler:
errors processed in .executetableoperationasync()
. samples catch mobileserviceconflictexception
, mobileservicepreconditionfailedexception
, exception
.
finally question(s):
i hope covered possible exceptions types above.
if use sync handler, mean don't need try-catch push/pull/purge/etc. operations? samples i've seen little confusing include (ad hoc resolution , sync handler) in same project...
you should place push/pull/etc. operations in try/catch block. there risk exception haven't thought of (including network going away, example) happen.
Comments
Post a Comment