WMI--Windows API--COINIT

150 篇文章 0 订阅
18 篇文章 0 订阅

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件643166601@qq.com

 

COM
COINIT
See Also  
A set of values from the COINIT enumeration is passed as the dwCoInit parameter to CoInitializeEx.
一个结果集来自COINIT枚举是被传递到CoInitializeEx的dwCoInit参数。
This value determines the concurrency model used for incoming calls to objects created by this thread.
这个值决定了使用这个线程创建对象调用对象的并发性模型。
This concurrency model can be either apartment-threaded or multi-threaded.
这个并发性模型可以是单元线程或多线程。
  Copy Code
typedef enum tagCOINIT {
    COINIT_MULTITHREADED     = 0x0,
    COINIT_APARTMENTTHREADED = 0x2,
    COINIT_DISABLE_OLE1DDE   = 0x4,
    COINIT_SPEED_OVER_MEMORY = 0x8,
} COINIT;
 

Elements
COINIT_MULTITHREADED

Initializes the thread for multi-threaded object concurrency (see Remarks).
初始化多线程为对象并发性(见备注)。
COINIT_APARTMENTTHREADED

Initializes the thread for apartment-threaded object concurrency (see Remarks).
初始化单元线程对象并发性(见备注)。
COINIT_DISABLE_OLE1DDE

Disables DDE for Ole1 support.
禁用DDE的Ole1支持。
COINIT_SPEED_OVER_MEMORY

Trades memory for speed.
交换内存的速度。
Remarks
When a thread is initialized through a call to CoInitializeEx, you choose whether to initialize it as apartment-threaded or multi-threaded by designating one of the members of COINIT as its second parameter.
当一个线程通过调用CoInitializeEx初始化时,你可以通过选择指定COINIT的一个成员作为第二个参数决定初始为单元线程或多线程。
This designates how incoming calls to any object created by that thread are handled, that is, the object's concurrency.
这指出如何进来调用到创建的任何对象的处理线程,也就是对象的并发性。
Apartment-threading, while allowing for multiple threads of execution, serializes all incoming calls by requiring that calls to methods of objects created by this thread always run on the same thread – the apartment/thread that created them.
单元线程,允许执行多线程,序列化所有请求进来调用的调用方法的创建的对象这个线程总是运行在相同的线程-创建他们的单元/线程。
In addition, calls can arrive only at message-queue boundaries (i.e., only during a PeekMessage, SendMessage, DispatchMessage, etc.).
此外,调用可以只可以到达消息队列边界。(即,只在PeekMessage, SendMessage, DispatchMessage等等)
Because of this serialization, it is not typically necessary to write concurrency control into the code for the object, other than to avoid calls to PeekMessage and SendMessage during processing that must not be interrupted by other method invocations or calls to other objects in the same apartment/thread.
因为这是序列化的,它不是典型的有必要去写入并发性对象的代码中,除了避免调用PeekMessage 和SendMessage处理的时候没有必要乞求中断其它方法或其他对象在相同的单元/线程中。
Multi-threading (also called free-threading) allows calls to methods of objects created by this thread to be run on any thread.
多线程(也称为自由线程)允许调用方法的对象创建,这个线程可在任何线程之上运行。
There is no serialization of calls – many calls may occur to the same method or to the same object or simultaneously.
没有序列化调用-许多调用可以在相同的方法或相同对象或同时地发生。

Multi-threaded object concurrency offers the highest performance and takes the best advantage of multi-processor hardware for cross-thread, cross-process, and cross-machine calling, since calls to objects are not serialized in any way.
多线程对象并发性提供了跟高的性能和使用多处理器硬件的优势最佳优势可以跨线程,跨进程,和跨机器调用,因为调用对象可以以任何方式不会被序列化。
This means, however, that the code for objects must enforce its own concurrency model, typically through the use of Win32 synchronization primitives, such as critical sections, semaphores, or mutexes.
这意味着,对象的代码必须迫使它自己的并发模型,统称通过使用Win32同步同步原语,像临界区,信号量,或互斥量。
In addition, because the object doesn't control the lifetime of the threads that are accessing it, no thread-specific state may be stored in the object (in Thread-Local-Storage).
此外,因为对象不能控制正在访问它的线程的生命周期,在对象中没有线程特定状态存储(在线程本地存储)。
Requirements
For an explanation of the requirement values, see Requirements (COM).

Windows NT/2000/XP: Requires Windows NT 4.0 or later.

Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.

Header: Declared in objbase.h.

See Also
Reference
CoInitializeEx

Concepts
Processes, Threads, and Apartments

Send comments about this topic to Microsoft.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值