Problem with a Progress bar

Linux specific forum
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Problem with a Progress bar

Post by Armoured »

Hi :)
How I can update a ProgressBarGadget from inside a thread?

note: The ProgressBarGadget is generated outside the thread


Thanks
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

SetGadgetState() and/or SetGadgetAttribute()... Does also work in a thread here, altough the ProgressBarGadget() has been created outside that thread.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Post by Armoured »

Hi AND51
SetGadgetState() and/or SetGadgetAttribute()... Does also work in a thread here, altough the ProgressBarGadget() has been created outside that thread.
Yes but the window isn't update immediately. I need to change the gadget state and view instantaneously the result in the GUI
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You can try to flush the events with "while windowevent() : wend"
Armoured
Enthusiast
Enthusiast
Posts: 365
Joined: Mon Jan 26, 2004 11:39 am
Location: ITALY
Contact:

Post by Armoured »

Fred wrote:You can try to flush the events with "while windowevent() : wend"
Thanks Fred and AND51 ;)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Fred wrote:You can try to flush the events with "while windowevent() : wend"
But not inside the thread! The thread cannot use WindowEvent() to receive events from windows that were not created by it.

In my current project, the main program creates a window and receives the WindowEvents. The thread updates the progressbar periodically with the method I described above.

The main thread, however (and that is the trick), does not use WaitWindowEvent(), but WaitWindowEvent(200), so even if there is no incoming event, the timeout will cause the program to update the progressbar.

Understand? :wink:

Happy coding, AND51
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply