스레드의 사용 예 2와 의뢰 (스레드 간 통화 제어) (시간을 절약하기 위해)

 개인 서브 tb_clientNumber_Leave (개체로 보낸 사람, EventArgs입니다으로 e)는 tb_clientNumber.Leave를 처리
        'getResultsCount_thread ()는
        '위 실행할 수있는 스레드 트랜잭션 수의 고객 번호로 직접 액세스,하지만 당신은 시간을 저장할 수 없습니다
        '여기 스레드 방법이다
        희미한 t =으로의 새로운 threading.Thread threading.Thread합니다 (AddressOf를 getResultsCount_thread)
        t .SetApartmentState (Threading.ApartmentState.STA)
        백그라운드에서 t.IsBackground = 진정한 '실행 (호스트가 폐쇄로)
        t.start ()
  최종 하위
 

 개인 서브 getResultsCount_thread () '주의 시간이 소요가 아닌 구체적인 방법에 실을 넣어 작업을 저장, 그렇지 않으면 할 수없는 시간
        희미한 strSelect에 = "SELECT COUNT (*)"
        isTesting하면 () 다음에
            strSelect에 & = strFromUAT
        그렇지
            strSelect에 & = strFromProd
        최종면
        strSelect에 & = "cst_id = '"& 및 String.format ( "{0 : 000000}"에 CInt ( tb_clientNumber.Text.Trim)) & " '및 acc_ind ='03 '"
        희미한 strCount03 = getDataString (strSelect에) '이 작업은 매우 시간이 많이 소요의 데이터베이스 쿼리입니다
        하지 특정 방법의 위임 호출에 실을 넣어주의, 시간이 많이 소요되는 작업 시간을 절약 할 그렇지 않으면 할 수없는'
        'Me.Invoke (뉴 _delegate (AddressOf를 UPDATETEXT), strCount03)'调用委托
        lbl_count03All.Invoke (새로운 액션 (하위 () '람다
                                                                    lbl_count03All.Text = strCount03
                                                                    lbl_count03All.Visible = TRUE
                                                              End Sub 참고
        ))
최종 하위
 

추천

출처www.cnblogs.com/gaoleionline/p/12061116.html