2010-05-27 6 views
4

안녕하세요이 같은 액티브가 : 브라우저가 FinalRelease가 호출되지 않습니다 방법을 폐쇄 그러나 ActiveX 컨트롤을 언로드 할 때 IE에서 어떤 이벤트가 발생합니까?

 
class CMyActiveX : 
    public CComObjectRootEx... 
    ... 
{ 
    HRESULT FinalContruct(){return S_OK;} 
    void Start() 
    { 
     // a new thread is created here for some task 
    } 
    void FinalRelease() 
    { 
     // if the thread is alive kill it 
    } 
} 

. 그래서 쓰레드는 살아 있고 출구에서 충돌이 발생합니다.

이것에 대한 아이디어가 있으십니까? 고맙습니다!

답변

1

컨트롤 : SetClientSite (NULL)이 IE에서 닫히거나 페이지를 떠날 때 안정적으로 호출되어 중요한 종료 작업을 수행한다는 것을 알았습니다. 이것은 IOleObjectImpl에서 메서드를 재정의합니다.

HRESULT CControl::SetClientSite(IOleClientSite *pClientSite) 
{ 
    if (!pClientSite) { 
     // Means IE is closing or about to, or at least 
     // that we've lost our place in the sun... 
     do shutdown stuff 
    } 
    IOleObjectImpl::SetClientSite(pClientSite); 
    if (pClientSite) { 
     .... 

MSDN - IOleObject::SetClientSite method

관련 문제