Code: Alles auswählen
while isthread(thread)
delay(100)
wend
debug "fertig"
Code: Alles auswählen
while isthread(thread)
delay(100)
wend
debug "fertig"
Code: Alles auswählen
Enumeration
#Window_0
EndEnumeration
Enumeration
#ButtonGadget_0
EndEnumeration
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, #PB_Ignore, 0, 157, 85, "#Window_0")
If CreateGadgetList(WindowID(#Window_0))
ButtonGadget(#ButtonGadget_0, 35, 25, 95, 30, "Start")
EndIf
EndIf
EndProcedure
OpenWindow_Window_0()
Global ThreadActiv.l
Procedure MyThread(ID)
For i = 0 To 10 ;
Delay(1000)
Next i
DisableGadget(#ButtonGadget_0, #False)
ThreadActiv = #False
EndProcedure
Repeat
Event = WaitWindowEvent(100)
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #ButtonGadget_0
If ThreadActiv = #False
SetWindowState(#Window_0, #PB_Window_Minimize)
DisableGadget(#ButtonGadget_0, #True)
hThread = CreateThread(@MyThread(), 0)
If hThread
ThreadActiv = #True
EndIf
EndIf
EndIf
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
If ThreadActiv = #True
KillThread(hThread)
EndIf
Break
EndIf
Default
If ThreadActiv = #False
SetWindowState(#Window_0, #PB_Window_Normal)
EndIf
EndSelect
ForEver
Code: Alles auswählen
Enumeration
#Window_0
EndEnumeration
Enumeration
#ButtonGadget_0
EndEnumeration
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, #PB_Ignore, 0, 157, 85, "#Window_0")
If CreateGadgetList(WindowID(#Window_0))
ButtonGadget(#ButtonGadget_0, 35, 25, 95, 30, "Start")
EndIf
EndIf
EndProcedure
OpenWindow_Window_0()
Procedure MyThread(ID)
For i = 0 To 10 ;
Delay(1000)
Next i
PostMessage_(WindowID(#Window_0), #WM_USER, #Null, #Null)
EndProcedure
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #ButtonGadget_0
If IsThread(hThread) = #False
SetWindowState(#Window_0, #PB_Window_Minimize)
DisableGadget(#ButtonGadget_0, #True)
hThread = CreateThread(@MyThread(), 0)
EndIf
EndIf
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
If IsThread(hThread)
KillThread(hThread)
EndIf
Break
EndIf
Case #WM_USER
DisableGadget(#ButtonGadget_0, #False)
SetWindowState(#Window_0, #PB_Window_Normal)
EndSelect
ForEver