문제

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