Hello,
I have a trouble with a the function PureLVSORT_SelectGadgetToSort() and PureCOLOR_SetGadgetColorEx() when I use it in a thread.
To test it, launch the simple application, and when it runs, move a window. On many PC multiCPU under XP you will have a invalid memory error on the instruction WaitWindowEvent(...
If you select only one CPU with the SetCPU_Affinity() or with the task manager of window the trouble doen't exist.
I would like to use all the power of my PC, if someone have an idea....
Code:
#Nb_Thread = 4
#Nb_Line = 10
#Nb_Colone = 40
#DELAY_FOR_SYSTEM = 1
#RGB_Interligne_list_CONTACT=$D1FCD3
#ALL_CPU = 0
#MSK_CPU_0 = $01
#MSK_CPU_1 = #MSK_CPU_0 <<1
#MSK_CPU_2 = #MSK_CPU_1 <<1
#MSK_CPU_3 = #MSK_CPU_2 <<1
Procedure SetCPU_Affinity(CPU.L)
If CPU
hProcess.L = GetCurrentProcess_ ()
SetProcessAffinityMask_ (hProcess, CPU)
EndIf
EndProcedure
Procedure test(i.L)
ThrdWin.L = OpenWindow(#PB_Any, 0, 0, 690, 300, "ListIconGadget "+Str(i), #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
LstIcon.L = ListIconGadget(#PB_Any, 10, 25, 680, 270, "Colonne ", 100)
For i = 2 To #Nb_Colone
AddGadgetColumn(LstIcon, i, "Colonne " + Str(i), GadgetWidth(LstIcon)/(#Nb_Colone+1))
Next
For i = 0 To #Nb_Line
AddGadgetItem(LstIcon, i, Str(i))
Next
PureCOLOR_SetGadgetColorEx(LstIcon, #PureCOLOR_SystemColor, #PureCOLOR_SystemColor, #RGB_Interligne_list_CONTACT, #PureCOLOR_LV_AlternateColors)
PureLVSORT_SelectGadgetToSort(LstIcon,#PureLVSORT_ShowClickedHeader_IconLeft)
Repeat : Until WaitWindowEvent(#DELAY_FOR_SYSTEM) = #PB_Event_CloseWindow
CloseWindow(ThrdWin)
EndProcedure
;- Main part
; Define how many CPU will run
SetCPU_Affinity(#ALL_CPU) ; All cpu available
;SetCPU_Affinity(#MSK_CPU_0) ;only CPU_0
For i=1 To #Nb_Thread
CreateThread(@test(),i)
Next
test(0)
End