Skip to content

Strange behavior of property in callback #607

Answered by ogoffart
DaMilyutin asked this question in Q&A
Discussion options

You must be logged in to vote

You are not supposed to block the UI thread or the eventloop will not run. So you must do the processing operation in a different thread, and use sixtyfps::invoke_from_event_loop from the other thread to communicate back to the UI thread.
Example: (I did not test it so you might need to do some fixes)

int main(int argc, char **argv)
{
    auto ui = AppWindow::create();

    auto do_job = [&ui]{
            sixtyfps::invoke_from_event_loop([&ui] {
                ui->set_progress(0.f);
            });
            for(int i = 1; i <= 100; ++i)
            {
                std::cout << "at i = " << i << std::endl; 
                // some data processing here (file reading, etc.)

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
5 replies
@DaMilyutin
Comment options

@ogoffart
Comment options

@DaMilyutin
Comment options

@ogoffart
Comment options

@DaMilyutin
Comment options

Answer selected by DaMilyutin
Comment options

You must be logged in to vote
3 replies
@bjorn
Comment options

@DaMilyutin
Comment options

@ogoffart
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants