c++ - future get is terminating the proggram -
i running process asynchronously using qevent, after process complete setting promise , trying using future function.
but not working asynchronously process, it's working in synchronous process
may know wrong doing.
code:
win::win(qobject *parent) : mycustomwidget(parent) { qdebug()<<execute().get(); } std::future<int> win::execute() { auto promise = std::make_shared<std::promise<int>>(); auto temp = [=] { ///process qdebug()<<"done"; promise->set_value(100); }; qapplication::postevent(this,new mycustomevent(temp)); ////qapplication::processevents() without line not working may know reason //// without line , without future working return promise->get_future(); }
Comments
Post a Comment