5 #include <samchon/library/EventDispatcher.hpp> 6 #include <samchon/library/Event.hpp> 7 #include <samchon/library/ProgressEvent.hpp> 11 # pragma comment(lib, "x64/Debug/SamchonFramework.lib") 13 # pragma comment(lib, "x64/Release/SamchonFramework.lib") 17 # pragma comment(lib, "Debug/SamchonFramework.lib") 19 # pragma comment(lib, "Release/SamchonFramework.lib") 37 new Event(
this, Event::ACTIVATE);
38 dispatch(shared_ptr<Event>(
new Event(
this, Event::ACTIVATE)));
40 for (
size_t i = 0; i < 100; i++)
42 this_thread::sleep_for(chrono::seconds(1));
43 dispatch(shared_ptr<Event>(
new ProgressEvent(
this, i + 1, 100)));
46 dispatch(shared_ptr<Event>(
new Event(
this, Event::COMPLETE)));
50 void handleActivate(shared_ptr<Event> event,
void *addiction)
52 cout <<
"Activated" << endl;
54 void handleComplete(shared_ptr<Event> event,
void *addiction)
56 cout <<
"Completed" << endl;
58 void handleProgress(shared_ptr<Event> event,
void *addiction)
60 cout << dynamic_pointer_cast<ProgressEvent>(event)->getPercent() * 100.0 <<
"%" << endl;
67 process.addEventListener(Event::ACTIVATE, handleActivate);
68 process.addEventListener(Event::COMPLETE, handleComplete);
69 process.addEventListener(ProgressEvent::PROGRESS, handleProgress);
Represent an event running on background.
Event representing a progress.
Abstract class for dispatching Event.