ApplicationContext.ExitThread 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
스레드의 메시지 루프를 종료합니다.
public:
void ExitThread();
public void ExitThread();
member this.ExitThread : unit -> unit
Public Sub ExitThread ()
예제
다음 코드 예제는 클래스 개요의 예제에서 발췌한 ApplicationContext 것입니다. 다음은 열려 있는 폼을 추적하고 모든 폼이 닫힌 경우 현재 스레드를 종료하는 예제입니다. 메서드 OnFormClosed 는 이벤트에 대 Closed 한 이벤트 처리기입니다. 열려 있는 폼 수가 0과 같으면 메서드를 호출하여 현재 스레드가 ExitThread 종료됩니다. 폼이 표시될 때 변수를 증가시키고 formCount 폼을 닫을 때 감소시켜 폼 수를 추적합니다.
간결성을 위해 일부 코드가 표시되지 않습니다. 전체 코드 목록을 참조하세요 ApplicationContext .
void OnFormClosed( Object^ /*sender*/, EventArgs^ /*e*/ )
{
// When a form is closed, decrement the count of open forms.
// When the count gets to 0, exit the app by calling
// ExitThread().
_formCount--;
if ( _formCount == 0 )
{
ExitThread();
}
}
private void OnFormClosed(object sender, EventArgs e)
{
// When a form is closed, decrement the count of open forms.
// When the count gets to 0, exit the app by calling
// ExitThread().
_formCount--;
if (_formCount == 0)
{
ExitThread();
}
}
Private Sub OnFormClosed(ByVal sender As Object, ByVal e As EventArgs)
' When a form is closed, decrement the count of open forms.
' When the count gets to 0, exit the app by calling
' ExitThread().
_formCount = _formCount - 1
If (_formCount = 0) Then
ExitThread()
End If
End Sub
설명
이 메서드는 ExitThreadCore를 호출합니다.
메모
ExitThread 실제로 ExitThreadCore 스레드가 종료되지 않도록 합니다. 이러한 메서드는 개체가 ThreadExit 수신 대기하는 Application 이벤트를 발생합니다. 그러면 개체가 Application 스레드를 종료합니다.