Print Page | Close Window

Background thread and PersistenceManager

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=791
Printed Date: 07-Apr-2025 at 4:53pm


Topic: Background thread and PersistenceManager
Posted By: BillG
Subject: Background thread and PersistenceManager
Date 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
 



Replies:
Posted By: davidklitzke
Date Posted: 29-Apr-2008 at 3:58pm

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



Posted By: f3rland
Date 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



Print Page | Close Window