Single EntityCollection2 instance with multiple EntityView2 instance. It's OK? It's threadsafe?

Posts   
 
    
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 18-Jun-2007 11:02:10   

I'm implementing an EntityCollection cache for my lookup table. My EntityCollectionCache class will hold a private dictionary of EntityType and EntityCollection2 reference.

EntityCollectionCache will have a method for returning a new instance of an EntityView2 based on one of the internally cached EntityCollection2.

So I will have multiple EntityView2 instance based on the same EntityCollection2 instance. These EntityView2 will be mainly used in ad WinForm databinding scenario.

The main purpose for the cached data is to fill different dropdown combo (the cached data are lookup table). So the cached data will be read-only.

Is this OK?

It's even possible that these EntityView2 instance, based n the same EntityCollection2 instance, are used on different thread (each thread will have it's own instance of EntityView2)

Is this OK in this a mutithread scenario? (only one thread will control the GUI, but maybe I will have concurrent thread doing some background elaboration)

some info: *) .Net 2.0, VisualStudio 2005 *) LLBLGenPro 2.0.0.0 Final (March 21st, 2007) *) Code generation: Adapter/VB.Net 2.0/Standard Templates+CommonBaseClass *) LLBLGenPro Lib 2.0.07.0416 *) Database: Access2k / SQL Server 2k

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 18-Jun-2007 15:55:41   

Hello,

as your cached data will be read-only, did you need an EntityView by thread?

Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 18-Jun-2007 17:39:02   

jbb wrote:

Hello,

as your cached data will be read-only, did you need an EntityView by thread?

In some situation I will use cached data in different thread.

Said that I have EntityCollection "EC" in my cache. In my application I have EntityViewA, EntityViewB and EntityViewC based on my cached EC.

EntityViewA and EntityViewB are used by the main GUI thread. EntityViewC is used in a background thread that is elaborating and printing a report.

In this situation, will everything work right? Or maybe that using the same entitycollection from multiple thread will mess-up something?

Thanks, Max

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39914
Joined: 17-Aug-2003
# Posted on: 18-Jun-2007 17:45:40   

A view refers to entity objects, so if you have 2 views on the same collection and one view is in thread A and another is in thread B and B changes a value in one of these entities, A will see that change. If you're not changing anything, it should be fine simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 18-Jun-2007 18:08:59   

Otis wrote:

A view refers to entity objects, so if you have 2 views on the same collection and one view is in thread A and another is in thread B and B changes a value in one of these entities, A will see that change. If you're not changing anything, it should be fine simple_smile

Perfect! Thanks simple_smile