質問

I need some kind of cross-process synchronisation object that will allow me to create and initialise an object once and then close and dispose it once only when the last instance exits.

e.g. lifetime would go something like:

new Instance 1: Create and initialise object

new Instance 2: Do nothing

delete Instance 1: Do nothing

delete Instance 2: Close and dispose object

I thought a named event might work, but I can't see how it can handle the out of order creation and disposal on instances.

役に立ちましたか?

解決

Use a semaphore with WaitOne() and Release() in your create and delete methods.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top