00001 /* 00002 Free Download Manager Copyright (c) 2003-2007 FreeDownloadManager.ORG 00003 Open Download Manager Copyright (c) 2008-2010 OpenDownloadManager.ORG 00004 */ 00005 00006 #include "stdafx.h" 00007 #include "FdmApp.h" 00008 #include "UIThread.h" 00009 00010 #ifdef _DEBUG 00011 #define new DEBUG_NEW 00012 #undef THIS_FILE 00013 static char THIS_FILE[] = __FILE__; 00014 #endif 00015 00016 IMPLEMENT_DYNCREATE(UIThread, CWinThread) 00017 00018 UIThread::UIThread() 00019 { 00020 } 00021 00022 UIThread::~UIThread() 00023 { 00024 } 00025 00026 BOOL UIThread::InitInstance() 00027 { 00028 OnDoWork (); 00029 return FALSE; 00030 } 00031 00032 int UIThread::ExitInstance() 00033 { 00034 00035 return CWinThread::ExitInstance(); 00036 } 00037 00038 BEGIN_MESSAGE_MAP(UIThread, CWinThread) 00039 //{{AFX_MSG_MAP(UIThread) 00040 ON_COMMAND(ID_UITHR_DOWORK, OnDoWork) 00041 //}}AFX_MSG_MAP 00042 END_MESSAGE_MAP() 00043 00044 void UIThread::set_Thread(LPTHREAD_START_ROUTINE pfn, LPVOID lpParam) 00045 { 00046 m_pfnThread = pfn; 00047 m_lpParam = lpParam; 00048 } 00049 00050 extern CFdmApp theApp; 00051 00052 void UIThread::OnDoWork() 00053 { 00054 AFX_MANAGE_STATE (theApp.GetModuleState ()); 00055 AfxEndThread (m_pfnThread (m_lpParam)); 00056 } 00057 00058 void UIThread::StartDoWork() 00059 { 00060 while (FALSE == PostThreadMessage (WM_COMMAND, ID_UITHR_DOWORK, 0)) 00061 Sleep (50); 00062 }
1.5.6