// The thread runs this method // Accept incoming connections from remote computers and figure out what they want void CHandshakes::OnRun() { // Loop while the socket is valid while ( IsThreadEnabled() && IsValid() ) { // Wait for a computer to call us, which fires the wakeup event Doze( 1000 ); // Accept the connection from the remote computer, making a new CHandshake object for it in the list while ( AcceptConnection() ); // Send and receive data with each remote computer in the list RunHandshakes(); // If we've listened for and accepted at least one connection, update the discovery services RunStableUpdate(); } }
void CLibraryTipCtrl::OnRun() { while ( IsThreadEnabled() ) { Doze( 1000 ); if ( ! IsThreadEnabled() ) break; m_pSection.Lock(); CString strPath = m_sPath; m_pSection.Unlock(); if ( strPath.IsEmpty() ) // ToDo: Make preview requests by hash? continue; CImageFile pFile; BOOL bSuccess = CThumbCache::Cache( strPath, &pFile ); m_pSection.Lock(); if ( m_bmThumb.m_hObject ) m_bmThumb.DeleteObject(); if ( m_sPath == strPath ) { m_sPath.Empty(); if ( bSuccess ) { m_bmThumb.Attach( pFile.CreateBitmap() ); Invalidate(); } } m_pSection.Unlock(); } }
void CPlugins::OnRun() { while ( IsThreadEnabled() ) { Doze( 1000 ); if ( ! IsThreadEnabled() ) break; if ( m_inCLSID == CLSID_NULL ) { m_pReady.PulseEvent(); continue; } CQuickLock oLock( m_pSection ); // Revoke interface CPluginPtr* pGITPlugin = NULL; if ( m_pCache.Lookup( m_inCLSID, pGITPlugin ) ) { delete pGITPlugin; TRACE( "Dropped plugin %s\n", (LPCSTR)CT2A( Hashes::toGuid( m_inCLSID ) ) ); } m_pCache.SetAt( m_inCLSID, NULL ); HINSTANCE hRes = AfxGetResourceHandle(); pGITPlugin = new CPluginPtr; if ( pGITPlugin ) { //HRESULT hr; // Create plugin & Add plugin interface to GIT if ( SUCCEEDED( /*hr =*/ pGITPlugin->m_pIUnknown.CoCreateInstance( m_inCLSID ) ) && SUCCEEDED( /*hr =*/ pGITPlugin->m_pGIT.Attach( pGITPlugin->m_pIUnknown ) ) ) { m_pCache.SetAt( m_inCLSID, pGITPlugin ); TRACE( "Created plugin %s\n", (LPCSTR)CT2A( Hashes::toGuid( m_inCLSID ) ) ); } else delete pGITPlugin; } AfxSetResourceHandle( hRes ); m_inCLSID = CLSID_NULL; m_pReady.SetEvent(); } CQuickLock oLock( m_pSection ); // Revoke all interfaces for ( POSITION pos = m_pCache.GetStartPosition() ; pos ; ) { CLSID pCLSID; CPluginPtr* pGITPlugin = NULL; m_pCache.GetNextAssoc( pos, pCLSID, pGITPlugin ); delete pGITPlugin; } m_pCache.RemoveAll(); }