Critical

현재 쓰레드가 다른 쓰레드에게 인터럽트 되지 않도록 방지합니다. 또는 인터럽트 되도록 활성화합니다.

Critical , OnOffNumeric

매개변수

OnOffNumeric

비어 있거나 생략하면, 기본값은 On입니다. Otherwise, specify one of the following:

On: The current thread is made critical, meaning that it cannot be interrupted by another thread.

Off: The current thread immediately becomes interruptible, regardless of the settings of Thread Interrupt. See Critical Off for details.

(Numeric) [v1.0.47+]: Specify a positive number to turn on Critical but also change the number of milliseconds between checks of the internal message queue. See Message Check Interval for details. [v1.0.48+]: Specifying 0 turns off Critical.

임계 쓰레드의 행위

Critical threads are uninterruptible; for details, see Threads.

임계 쓰레드는 메시지 박스를나 기타 대화상자가 화면에 나타나면 인터럽트될 수 있습니다. 그렇지만, Thread Interrupt과 다르게, 이 쓰레드는 사용자가 대화상자를 취소하고 나면 다시 임계 쓰레드가 됩니다.

Critical Off

버퍼 처리된 이벤트가 새로운 쓰레드가 시작되기를 기다리고 있을 때, Critical Off를 사용하면 현재 쓰레드를 즉시 인터럽트하지 않습니다. 대신에, 평균 5 밀리초가 지난 다음 인터럽트가 일어납니다. 이렇게 하면 Critical Off 뒤에 적어도 한 줄이 인터럽트 전에 실행될 확률이 99.999% 이상입니다. 강제로 인터럽트를 즉시 일어나게 할 수 있습니다. 아직 존재하지 않는 창에 대하여 Sleep -1 또는 WinWait와 같은 지연을 사용하면 됩니다.

Critical Off는 현재 쓰레드가 임계 쓰레드가 아니었더라도 그의 인터럽트 불가침성을 취소합니다. 그러므로 GuiSize와 같은 이벤트를 더 빨리 더 예측 가능하게 처리할 수 있습니다.

쓰레드 설정

임계값의 현재 설정을 저장하고 복구하는 법은 A_IsCritical을 참조하십시오. 그렇지만, 임계값은 쓰레드에-종속적인 설정이므로, 임계 쓰레드가 끝나면, 그 아래의/재개된 쓰레드는 (있다면) 자동으로 비임계 쓰레드가 됩니다. 결론적으로 쓰레드를 끝내기 바로 전에 Critical Off를 할 필요가 없습니다.

자동 실행 섹션에 (스크립트이 상단 부분) 임계값이 사용되지 않으면, 모든 쓰레드는 비임계 값으로 시작합니다 (그렇지만 Thread Interrupt 설정을 영향을 미칩니다). 대조적으로, 자동-실행 섹션에서 임계값을 켜고 다시 끄지 않으면, 새로 기동하는 매 쓰레드마다 (핫키, 맞춤 메뉴 항목, 또는 시간 제한 서브루틴 등은) 임계값으로 시작합니다.

명령어 Thread NoTimers는 Critical과 비슷하지만 타이머의 인터럽트만 방지한다는 점이 다릅니다.

[v1.0.47+]: Critical을 켜두고 SetBatchLines -1를 배치하면 현재 쓰레드에 영향을 미칩니다.

메시지 점검 간격

[v1.0.47+]: Specifying a positive number as the first parameter (e.g. Critical 30) turns on Critical but also changes the minimum number of milliseconds between checks of the internal message queue. If unspecified, the default is 16 milliseconds while Critical is On, and 5 ms while Critical is Off. 점검 간격을 증가시키면 메시지/이벤트의 도착을 지연시킵니다. 그래서 현재 쓰레드는 더 시간을 가지고 종료할 수 있습니다. 이렇게 하면 "이미 실행 중인 쓰레드 때문에" 어떤 OnMessage() 그리고 GUI 이벤트가 소실될 가능성이 줄어듭니다. 그렇지만, SleepWinWait같은 대기 명령어는 이 설정에 관계 없이 메시지를 점검합니다 (우회책은 DllCall("Sleep", Uint, 500)입니다).

Because the system tick count generally has a granularity of 15.6 milliseconds, the minimum delta value is generally at least 15 or 16. The duration since the last check must exceed the interval setting in order for another check to occur. For example, a setting of 16 requires the tick count to change by 17 or greater. As a message check could occur at any time within the 15.6 millisecond window, any setting between 1 and 16 could permit two message checks within a single interval.

주의: 메시지-점검 간격을 너무 많이 늘리면 GUI 창 다시 그리기와 같은 다양한 이벤트에 반응하지 못할 수 있습니다.

Thread (command), Threads, #MaxThreadsPerHotkey, #MaxThreadsBuffer, OnMessage(), RegisterCallback(), Hotkey, Menu, SetTimer

예제

Press a hotkey to display a tooltip for 3 seconds. Due to Critical, any new thread that is launched during this time (e.g. by pressing the hotkey again) will be postponed until the tooltip disappears.

#space::  ; Win+Space 핫키.
Critical
ToolTip 이 툴팁이 사라진 후에만 새 쓰레드가 시작합니다.
Sleep 3000
ToolTip  ; 팁을 끕니다.
return  ; 핫키 서브루틴으로부터 반환되면 쓰레드가 종료됩니다. 재개 될 아래의 쓰레드는 정의상 임계값이 아닙니다.