FLTK logo

Re: [fltk.general] Use worker thread to call Fl_Window and Fl_run

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Use worker thread to call Fl_Window and Fl_run Greg Ercolano Sep 30, 2020  
 
On 2020-09-30 13:54, Ian MacArthur wrote:
> However, the key here is that you do not need to call Fl::run() at all, if you only want to drive the GUI from your main thread: all you have to do is call Fl::wait(0); every now and then (say every 100ms or so if you just want to update the GUI but not handle user input...)
	I believe we have an example of this in examples/progress-simple.cxx, which shows:

[..]
    // Computation loop needing an updating progress indicator..
    for ( int t=1; t<=500; t++ ) {
        progress->value(t/500.0);              // update progress bar with 0.0 ~ 1.0 value
        char percent[10];
        sprintf(percent, "%d%%", int((t/500.0)*100.0));
        progress->label(percent);              // update progress bar's label
        Fl::check();                           // give fltk some cpu to update the screen
        usleep(1000);                          // <-- your compute intensive stuff goes here
    }
[..]

-- 
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/944a5b7f-a1ab-87fb-bfc5-3a043ef67657%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.