简体   繁体   English

同步对象仅用于创建一次对象

[英]Sync object for creating an object once only

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. 我需要某种跨进程同步对象,该对象将允许我一次创建和初始化一个对象,然后仅在最后一个实例退出时关闭并处置一次。

eg lifetime would go something like: 例如,生命将会像:

new Instance 1: Create and initialise object 新实例1:创建并初始化对象

new Instance 2: Do nothing 新实例2:什么都不做

delete Instance 1: Do nothing 删除实例1:什么都不做

delete Instance 2: Close and dispose object 删除实例2:关闭并释放对象

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. 我认为命名事件可能有效,但我无法看到它如何处理实例上的乱序创建和处理。

创建删除方法中,将信号灯WaitOne()Release()一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM