Did you try to add "WindowEvent()" in your DoLotsOfStuff loop(s) ?
Does it solve the blanking problem ?
Even if old masters think it's a crapy solution, we may get a hint of what's going on that way.
Controls "Blanking Out" [False Alarm by Noob]
Re: Controls "Blanking Out" or Disappearing
There are 2 methods to program bugless.
But only the third works fine.
Win10, Pb x64 5.71 LTS
But only the third works fine.
Win10, Pb x64 5.71 LTS
Re: Controls "Blanking Out" or Disappearing
Shoot in the dark
Try
Or as a workaround
Try
Code: Select all
event = WaitWindowEvent(15)
Code: Select all
HideWindow(#Window_mainForm,1)
do_something()
HideWindow(#Window_mainForm,0)
Egypt my love
Re: Controls "Blanking Out" or Disappearing
With your test program it certainly behaves as expected in that the GUI appears to freeze and is unresponsive (though it doesn't blank here) when the heavy processing is in full swing. To be expected because no processing of event messages is being performed.
The only way as I see it to perform GUI event processing during those massive sortarray's is to use a separate thread for the data processing.
The only way as I see it to perform GUI event processing during those massive sortarray's is to use a separate thread for the data processing.
Code: Select all
Global gThread
Enumeration
#Window_mainForm
#do_btn
#listview1
#listview2
EndEnumeration
EnableExplicit
Procedure.i Window_mainForm()
If OpenWindow(#Window_mainForm,0,0,600,600,"Test Blankout",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
ButtonGadget(#do_btn,450,15,90,30,"Do Something")
ListViewGadget(#listview1,10,10,400,280)
ListViewGadget(#listview2,10,300,400,280)
ProcedureReturn 1
EndIf
EndProcedure ;Window_mainForm()
Procedure load_listview()
AddGadgetItem(#listview1, -1, "item 0")
AddGadgetItem(#listview1, -1, "item 1")
AddGadgetItem(#listview1, -1, "item 2")
AddGadgetItem(#listview1, -1, "item 3")
AddGadgetItem(#listview1, -1, "item 4")
AddGadgetItem(#listview1, -1, "item 5")
AddGadgetItem(#listview1, -1, "item 6")
AddGadgetItem(#listview1, -1, "item 7")
AddGadgetItem(#listview2, -1, "item 0")
AddGadgetItem(#listview2, -1, "item 1")
AddGadgetItem(#listview2, -1, "item 2")
AddGadgetItem(#listview2, -1, "item 3")
AddGadgetItem(#listview2, -1, "item 4")
AddGadgetItem(#listview2, -1, "item 5")
AddGadgetItem(#listview2, -1, "item 6")
AddGadgetItem(#listview2, -1, "item 7")
EndProcedure
Procedure do_something(value)
Protected i, j.f, k.f, size, iterations
size = 2*1000*1000*100 ; ~10 seconds to process
iterations = 1
Dim testarray.f(size)
For i = 1 To iterations
; CreateFile(1,"erase_me.txt")
; WriteStringN(1, "a line of text")
; CloseFile(1)
; DeleteFile("erase_me.txt")
j = i
k = j / 0.5347
testarray(i) = k
SortArray(testarray(),#PB_Sort_Descending)
Next i
MessageRequester("","Done")
gThread = 0
EndProcedure
Define event
Define quitmainForm=0
Define windowOpened
Define thread
windowOpened = Window_mainForm()
If windowOpened
load_listview()
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Window_mainForm
quitmainForm=1
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #do_btn
Select EventType()
Case #PB_EventType_LeftClick
If gThread = 0
gThread = CreateThread(@do_something(), 0)
EndIf
EndSelect
EndSelect ;EventGadget()
EndSelect ;event
Until quitmainForm
If gThread
KillThread(gThread)
EndIf
CloseWindow(#Window_mainForm)
EndIf ;windowOpened
I may look like a mule, but I'm not a complete ass.
Re: Controls "Blanking Out" or Disappearing
Fig, RASHAD I will try these tonight after work (in the interests of Science, ahem).
SRod I think we need to recreate the blanking if anybody is up to it. Having the user wait is not a problem. People are used to that. I could throw up a little "Processing..." window if I had to. They are not used to the GUI having an apparent stroke.
Maybe I should try to blank it with a large matrix of controls.......
SRod I think we need to recreate the blanking if anybody is up to it. Having the user wait is not a problem. People are used to that. I could throw up a little "Processing..." window if I had to. They are not used to the GUI having an apparent stroke.
Maybe I should try to blank it with a large matrix of controls.......
Re: Controls "Blanking Out" or Disappearing
Well, when you 'freeze' a GUI due to an absence of event processing (especially with a complex GUI) then temporary blanking is not something that entirely surprises me, especially if you are using panel gadgets! It is not something which I've seen very often, but I have seen that sort of thing.
You want to fix it properly... move the data processing to a thread or some such and allow the GUI event handling to continue.
You want to fix it properly... move the data processing to a thread or some such and allow the GUI event handling to continue.
I may look like a mule, but I'm not a complete ass.
Re: Controls "Blanking Out" [False Alarm by Noob]
Well I found the cause of the blanking. In all this processing I was packing and unpacking some files. One earlier problem I had with that was the persistence of intermediate files in those processes in Explorer even after the process deleted them. I added an explorer window refresh routine (at the ends of the pack/unpack routines) to take care of that. http://www.purebasic.fr/english/viewtop ... 13&t=66810 Commenting out the refresh routines fixed the problem. I will either do without the window refresh or move it elsewhere where it happens in the blink of an eye.
So, once again, PB stands supreme in the world of programming. I apologize for not figuring this out sooner and for exercising anyone unduly.
[Tadpole wriggles back into the murky depths....]
So, once again, PB stands supreme in the world of programming. I apologize for not figuring this out sooner and for exercising anyone unduly.
[Tadpole wriggles back into the murky depths....]