如何在 Windows C++ 中设置自定义事件和事件处理程序?
我想要完成的模拟类似于在 nodejs 中所做的事情:
//in main execution context:
var app = require('myapp');
app.on('ready', function(){
//An event handler for the ready event
})
var i = 10;
foo(i);
//... do other stuff
================================================
//in a different execution context:
app.doStuff();
app.emit("ready");
用于设置和事件处理程序并继续执行的 Windows C++ 机制是什么?
最佳答案
事件处理程序是一个抽象概念,以某种方式存在于所有通用编程语言中。
C++ 也不异常(exception)。 对于 Windows 下的 C++,您可以定义自定义事件、引发此事件的源以及接收器或事件监听器/处理程序。
在这里检查示例代码
https://learn.microsoft.com/en-us/cpp/cpp/event-handling-in-native-cpp
关于c++ - 如何在 Windows C++ 中处理事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36465036/