WP7 - Ideal Project structure with scheduletaskproject
For my WP7 app I currently have a the Main application Project - call it say"MainProj' and another Project which is a class library Project where I have defined my database (its a Sterling DB). Lets call this project 'DBProject'.
Included in my 'MainProj' are my Views, ViewModels and a dataservice that retrieves data from the database. 'MainProj' includes a reference to 'DBProj'
I an now including a PeriodicTask, so have added a third project - 'scheduletaskproject'. My 'MainProj' references this and includes to fire off the Periodic task and its all working fine.
I am now about to extend my PeriodTask code, and, the code I want to access the database etc is all in my 'MainProj'. I cannot add that as a reference as that will create a crircular reference. Seems that I will have to refactor alot of code out to make it accessible to both applications including the dataservice. I was possibly even going to utilise one of my viewmodels but suspect that may not be the right thing to do.
So just looking for advi开发者_如何学JAVAce as to what theright approach should be here as I clearly have to refactor some code. As per a comment on a previous query, seems that there is a 5MB memory limit in the Periodic TAsk that may be awlward if I am accessing a database. Are there any techiques in terms of refactoring the code that could help here?
- thanks
You should move all code the ScheduledTask will reference to a separate assembly. Not only because of the memory limitations, but also because the ScheduledTask assembly cannot reference any code whatsoever that uses APIs that isn't supported in a Task (and there's quite a few of those).
精彩评论