我有一个班子,可以由多个校对。
在这一类别中,有<条码>[现成]条码>变量,储存各种物体。
我现在需要我的班子的二例,我希望在会场内有一个单独的物体库。
Currently, two instances in the same thread will share the same object store. I do not want this.
我认为的唯一解决办法是:
具有静态的<代码>IDictionary<int,bjectStore>,int
is the thread id,并通过某种方法或途径:
static TObjectStore ObjectStore {
get {
// create the instance here if its the first-access from this thread, with locking etc. for safety
return objectStore[Thread.CurrentThread.Id];
}
}
The problem with this though is how do I dispose of the TObjectStore
for a particular thread when it ends? I think im right in assuming that with my current implementation, the GC will simply pick it up?
增 编