0

How would I setup a custom event and event handler in Windows C++?

An analog for what I want to accomplish would be something similar to what this is doing in 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");

What is the Windows C++ mechanism for setting and event handler and continuing execution?

tt9
  • 5,784
  • 6
  • 42
  • 65

1 Answers1

1

Event handler is an abstract concept that exists somehow is all general purpose programming languages.

C++ is no exception. For C++ under windows you can define a custom event, a source that will raise this event, and a receiver or an event listener/handler.

Check the sample code here

https://learn.microsoft.com/en-us/cpp/cpp/event-handling-in-native-cpp

Community
  • 1
  • 1
Rami
  • 7,162
  • 1
  • 22
  • 19
  • Huh, alright, I guess I was expecting something built into C++ for custom events. Thanks! – tt9 Apr 07 '16 at 14:44
  • Check these posts too: http://stackoverflow.com/questions/9711414/what-is-the-proper-way-of-doing-event-handling-in-c and http://stackoverflow.com/questions/7464025/designing-an-event-mechanism-in-c – Rami Apr 07 '16 at 23:25