必须添加 #include <windows.h> 才能对事件使用多线程处理
如果将多线程用于事件,则需要 windows.h 文件。 若要修复此错误,请将 #include <windows.h>
添加到在其中定义事件源和事件接收器的文件的顶部。
// C3724.cpp
// uncomment the following line to resolve
// #include <windows.h>
[event_source(native), threading(apartment)]
class CEventSrc {
public:
__event void event1(); // C3724
};
[event_receiver(native)]
class CEventRec {
public:
void handler1() {
}
void HookEvents(CEventSrc* pSrc) {
__hook(CEventSrc::event1, pSrc, CEventRec::handler1);
}
void UnhookEvents(CEventSrc* pSrc) {
__unhook(CEventSrc::event1, pSrc, CEventRec::handler1);
}
};
int main() {
}