New Posts New Posts RSS Feed: Background thread and PersistenceManager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Background thread and PersistenceManager

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Background thread and PersistenceManager
    Posted: 29-Apr-2008 at 1:07pm
In my app, I want to have a background worker that just looks at the memos table in the database and sees if any new memos have been sent to the current logged in user.  If there is, it's going to alert the user that a new memo has arrived.
 
Is it ok to use the default PersistenceManager for this or should I create a new PersistenceManager for the background worker?  There will never be any relationship between them or need to share data between them.
 
the sole purpose of the thread is just to monitors memos being inserted into the Memo table.
 
Bill
 
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 29-Apr-2008 at 3:58pm

I'd use two different Persistence Managers, each with their own cache. 

Back to Top
f3rland View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Sep-2007
Location: Canada
Posts: 25
Post Options Post Options   Quote f3rland Quote  Post ReplyReply Direct Link To This Post Posted: 01-May-2008 at 8:12am
"Each GetEntitiesAsync method runs the query asynchronously per the specified strategy and updates the PersistenceManager with retrieved entities. The second overload (a "Timer-Triggered" query) performs the query repeatedly at the millisecond intervals specified in the TimerInteval parameter. "

Search for "GetEntitiesAsync" in the Developers Guide. I think this will be easier to implement. One line of code and your cache will be automatically updated at specified interval. No mess with thread and/or cross-thread errors, persistencemanager merging, etc.

Thumbs%20Up to GetEntitiesAsync!!
F3
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down