dimanche 28 juin 2015

SQLite via Application and Service (.NET)

I'm writing an application (single user, WPF) that I want to use a local sqlite database for. SQLite is a perfect fit, except that I also want to run an (optional) service related to that application that would use the same database.

I've done some reading on async calls (mostly android stuff, where I'm working in WPF but that doesn't matter), but haven't found much on having two separate applications possibly working at the same time.

One idea is to have the service lock itself if it detects the application open or idle. This could work in a worst case, but I'd like better.

Another idea was a possible global queue which would take requests from both the app and the service, and handle processing them to be sure there's no concurrency issues, but this feels like a bad approach and overcomplication.

My gut feel is to follow the "run service on app not open or idle", but I'm curious how I might handle the possibility of the app being opened/awakened during a long-ish service process. Transaction times wouldn't exceed more than a few seconds at most - maybe 10 on extreme edges, but small windows are still windows. As these "longer" transactions will be known, I'm considering writing to file/reg when it's started and having the app check on that and hold upon startup/awaken.

Does anyone have any insight on how this might be best arranged? If anyone has tackled a similar scenario and has any insight that'd be great. Thanks

Aucun commentaire:

Enregistrer un commentaire