Modify

Opened 9 years ago

Last modified 6 years ago

#1652 reopened Bug

Sleep in TimerFunc

Reported by: hunt Owned by: Jpm
Milestone: Component: AutoIt
Version: 3.3.6.0 Severity: None
Keywords: Cc:

Description

Form does not close on the first try because of sleep in TimerFunc.

#Include <Timers.au3>
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

$hGUI = GUICreate("Form", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "__Exit")
GUISetState()

_Timer_SetTimer($hGUI, 10, "__Timer")

While 1
    Sleep(10)
WEnd

Func __Timer($hWnd, $Msg, $iIDTimer, $dwTime)
	Sleep(1)
EndFunc

Func __Exit()
	_Timer_KillAllTimers($hGUI)
    Exit
EndFunc

Attachments (0)

Change History (10)

comment:1 Changed 9 years ago by hunt

I think when i trying to close script first time then script kills timer and stops before Exit. And when i trying to close script second time then script closes normally.

comment:2 Changed 9 years ago by Jpm

I found the problem. It is related really to Sleep().
The same problem can occur on ProcessWait(), ProcessWaitClose(), RunWait() RunAsWait() and ShellExecuteWait().
I intend to return failure on those when the situation occurs.

comment:3 Changed 9 years ago by anonymous

Jpm I think - this problem has not been if not executed function of timer before "Exit Function(s)". In example below TimerFunc not executes while calls function _Test in loop but executes before Exit! Why?

#Include <Timers.au3>
#include <GUIConstantsEx.au3>

Global $BeforeExit = 0

Opt("GUIOnEventMode", 1)

$hGUI = GUICreate("Form", 200, 100)
GUICtrlCreateButton("test",4,4,100,50)
GUISetOnEvent($GUI_EVENT_CLOSE, "__Exit")
GUISetState()

_Timer_SetTimer($hGUI, 10, "__Timer")


While 1
    Sleep(10)
WEnd


Func __Timer($hWnd, $Msg, $iIDTimer, $dwTime)
	If $BeforeExit = 1 Then ConsoleWrite("Entered here before Exit" & @CRLF)
	;Sleep(1)
EndFunc


Func __Exit()
	_Timer_KillAllTimers($hGUI)
	$BeforeExit = 1
	For $i = 1 to 999999
		_Test()
	Next
    Exit
EndFunc


Func _Test()
EndFunc

comment:4 Changed 9 years ago by Jpm

This ticket is referenced in revision: [5862]

comment:5 Changed 9 years ago by Jpm

  • Milestone set to 3.3.7.0
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5863] in version: 3.3.7.0

comment:6 Changed 9 years ago by Jpm

This ticket is referenced in revision: [5864]

comment:7 Changed 8 years ago by Jon

  • Resolution Fixed deleted
  • Status changed from closed to reopened

comment:8 Changed 8 years ago by TicketCleanup

  • Milestone 3.3.7.0 deleted

Automatic ticket cleanup.

comment:9 Changed 6 years ago by Jon

  • Resolution set to Rejected
  • Status changed from reopened to closed

comment:10 Changed 6 years ago by Jpm

  • Resolution Rejected deleted
  • Status changed from closed to reopened

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as reopened The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.