Using Sterling from app and background agent

Oct 5, 2011 at 3:01 PM

Is using the same Db between a WP7 app and a WP7 background agent ok?

Nov 18, 2011 at 8:19 PM

Have you been able to achieve this?  If so, how and anything should watch out for?

Nov 29, 2011 at 7:50 PM

It seems to work fine.  I haven't had any issues, yet.

Dec 11, 2011 at 6:24 AM
Edited Dec 11, 2011 at 6:33 AM

I have an object with a WriteableBitmap property.  When querying from my background agent the ExtendedSerializer throws an "Invalid cross-thread access." exception.  This makes sense, I wouldn't think the background agent works on the UI thread.  When I think about it, WriteableBitmap is very UI focused and it's probably better to store the image as a byte[] and convert to WriteableBitmap in the UI.  Just wanted to throw that out there as a design consideration for apps with background agents.

Nov 13, 2012 at 11:51 AM

I'm having issues deleting entities in a background agent. When the app tries to read from isolated storage once the background agent has run - I get an EndOfStreamException.

The same task running from within the app works fine.

Mar 1, 2013 at 10:08 PM
Edited Mar 2, 2013 at 4:26 AM
I know the MSDN docs suggest utilizing a Mutex to coordinate access from the background agent and foreground app, though right now I'm only doing read-only from my agent (and have yet to test Sterling with it, which I will be doing tonight or this weekend).

From MSDN:
The Mutex class should be used to synchronize access to resources that are shared between the foreground application and the background agent, such as files in isolated storage.
EDIT: I checked the source and Sterling already uses a locking mechanism... which would/should coordinate between the background and foreground, but I'm not 100% positive.