Speed up filling ListiconGadget from thread?
Posted: Sun Sep 12, 2021 12:30 am
I am filling a ListiconGadget with a lot of lines so i put it into a seperate thread to not lock up the program, hower this seems to significantly slow it down with thread safe on or off, i also notice that SetGadgetItemColor from a thread is very slow too.
My Times are 2000ms filling from thread and 400ms from the main, and with SetGadgetItemColor commented out i get 600ms from thread and 200ms from main.
is there any way to speed this up?
My Times are 2000ms filling from thread and 400ms from the main, and with SetGadgetItemColor commented out i get 600ms from thread and 200ms from main.
is there any way to speed this up?
Code: Select all
Procedure.i Fill(Listicon.i)
SendMessage_(GadgetID(Listicon), #WM_SETREDRAW, 0, 0)
For I = 0 To 5000
AddGadgetItem(Listicon, -1, "Test " + I)
SetGadgetItemColor(Listicon, I, #PB_Gadget_BackColor, #Green) ; Comment out for speedup
Next
SendMessage_(GadgetID(Listicon), #WM_SETREDRAW, 1, 0)
EndProcedure
Define MainWindow.i = OpenWindow(#PB_Any, 0, 0, 500, 500, "MainWindow", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
Define Listicon.i = ListIconGadget(#PB_Any, 0, 0, 500, 500, "Test", 480)
Timer.i = ElapsedMilliseconds()
Thread.i = CreateThread(@Fill(), Listicon)
While (IsThread(Thread)) : WaitWindowEvent(10) : Wend
Debug ElapsedMilliseconds() - Timer
ClearGadgetItems(Listicon)
Timer.i = ElapsedMilliseconds()
SendMessage_(GadgetID(Listicon), #WM_SETREDRAW, 0, 0)
For I = 0 To 5000
AddGadgetItem(Listicon, -1, "Test " + I)
SetGadgetItemColor(Listicon, I, #PB_Gadget_BackColor, #Green)
Next
SendMessage_(GadgetID(Listicon), #WM_SETREDRAW, 1, 0)
Debug ElapsedMilliseconds() - Timer
Repeat
WaitWindowEvent()
ForEver