Page 1 of 1

How to use IsThread()

Posted: Sat Mar 02, 2024 7:57 pm
by matalog
I have a program that I expected debug to return a non-zero value upon the 2nd press of Key e, but t doesn't, so I must be labelling the thread wrong?

How do I tell IsThread which thread i'm referring to?

Code: Select all

Enumeration
  #Menu_E
EndEnumeration
OpenWindow(0,0,0,100,100,"Window")
AddKeyboardShortcut(0, #PB_Shortcut_E, #Menu_E)

Procedure wastetime(null)
  For x=1 To 10000
    For y=1 To 100000
      For z=1 To 100000000
        For a=1 To 100000000
          x=Sqr(Pow(2,Pow(2,2)))
        Next
      Next
    Next
  Next
EndProcedure

Repeat 
  event=WaitWindowEvent()
  gadget=EventGadget()
  Select event
    Case #PB_Event_Menu
      Select EventMenu()
        Case #menu_E
          Debug IsThread(@wastetime)
          If IsThread(@wastetime())=0
            CreateThread(@wastetime(),0)
          EndIf
      EndSelect
  EndSelect
Until quit=#True
End 
I have tried:

Code: Select all

          Debug IsThread(wastetime)
          If IsThread(@wastetime())=0


And also

Code: Select all

          Debug IsThread(@wastetime())
          If IsThread(@wastetime())=0

Re: How to use IsThread()

Posted: Sat Mar 02, 2024 8:28 pm
by DarkDragon
You have to pass the return value of CreateThread to IsThread. You can create multiple threads with the same procedure.

Re: How to use IsThread()

Posted: Sat Mar 02, 2024 9:44 pm
by matalog
Thanks, that is good to know. I don't think the help files make that clear.

Re: How to use IsThread()

Posted: Sun Mar 03, 2024 12:44 am
by juergenkulow