How to use IsThread()

Just starting out? Need help? Post your questions and find answers here.
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

How to use IsThread()

Post 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
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: How to use IsThread()

Post by DarkDragon »

You have to pass the return value of CreateThread to IsThread. You can create multiple threads with the same procedure.
bye,
Daniel
User avatar
matalog
Enthusiast
Enthusiast
Posts: 305
Joined: Tue Sep 05, 2017 10:07 am

Re: How to use IsThread()

Post by matalog »

Thanks, that is good to know. I don't think the help files make that clear.
Post Reply