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 스레드를 종료합니다.
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기