void CMyThread::ThreadStart() { if (m_pSelThread != NULL) // CWinThread* m_pSelThread; { if (::WaitForSingleObject(m_pSelThread->m_hThread, 0) != WAIT_OBJECT_0) return; delete m_pSelThread; m_pSelThread = NULL; } m_pSelThread = AfxBeginThread((AFX_THREADPROC)ThreadFunction, this, THREAD_PRIORITY_NORMAL, 0,CREATE_SUSPENDED); m_pSelThread->m_bAutoDelete = FALSE; m_pSelThread->ResumeThread(); } UINT CMyThread::ThreadFunction ( LPVOID param ) { while(!bTerminate) // bool bTerminate { if ((::WaitForSingleObject(m_Sel_End_Event, 0) == WAIT_OBJECT_0)) { bTerminate = true; continue; } }
susanne1
Posts
-
Thread paused -
Thread pausedi changed the thread priority to HIGHEST, but it didi not help.
-
Thread pausedI have a thread, it is has a normal priority, when it starts to excute, it runs for 5 or 6 seconds then stops for 3 or 4 seconds and run again, stops again this goes till it finishes his work. Any idea why this happens, programm code is in Visual C++. Thanks
-
Blinking cursorThe reason that in the Output view will be alot of output lines over 40000 lines and the a view derived from CEditView or CRichEditView will not give it on the screen like it should without using a very complicated code, so i am must use a view derived from CView. I used CreateCaret and ShowCaret() but they did not solve the problem.
-
Blinking cursorSorry for not replaying was sick. I can not use CEditView, CRichEditView, because this is the requirments of my Boss, i would like too but it will make complicates somewhere else.
-
Blinking cursorHallo, i have SDI Application i need to get a blinking cursor when i click the Left mouse button(i have the fucntion OnLButtonUp(UINT nFlags,CPoint point) already, also i have the position where the mouse click happend, my View class is derived from CView Class. but i do not know how to darw the cursor that blinks),Please help.
-
SDI Applicationi need to print out the results of a database query, a class derived directly from CView is the only suitable possible solution till now i had before classes derived from CRichEditView and CEditView buut i hhad a lot of disadvanteges and ristrictions with them.
-
SDI ApplicationThe problem is i do not have a blinking cursor., because this is a view derived from CView calss.
-
SDI ApplicationHallo, i have an SDI-Application it is View class derived directly from CView, i need tob e able to change the output in it or to move the cursor with ctrl+pos1 or ctrl+end .Important: I can not use the class CRichEditView instead of CView to drive the View of my application. Thanks.
-
How to terminate the secondary thread when the application closed?thanks. I am using SDI application, so i will put the code in BOOL OnNewDocument() instead of OnInitDialg(). Now a general question: why can i not use ON_WM_CLOSE() to tell the small thread to terminate himself and if yes how? Thanks a lot
-
How to terminate the secondary thread when the application closed?bool PrintMy Results(const CString& strMyResult) { bool bTerminate = false; while(!bTerminate && nCount < arrMyResults.GetSize()) { if (::WaitForSingleObject(m_End_Event.m_hObject, 0) == WAIT_OBJECT_0) { bTerminate = true; continue; } nCount++; // Code to print the Array-Elements // I am hier inside the secondary thread wich is in another // class as the Doc class, how can I till him hier that the //application is going to be finsihed and he must finsh the printing //of the last line of the Array? } }
-
How to terminate the secondary thread when the application closed?Hallo, I have an application that uses a secondary thread to excute a very long function, what i need is, how to terminate the secondary thread "CLEANLY" if the main appliction is going to be closed while the seconndary thread is still excuting the verx long function? i started with : ON_WM_Close() in the View.cpp file, but i do not know how to continue: The secondary thread should become a Message if the the x or End in the Main application werde clicked. Please help(with code).
-
Threadthe thread mus t be created but not start immediately, autodelte false to tell him not to delet himself.
-
Threadto wait for the event to happen.
-
ThreadOkay i did it like that defining the Thread Pointer in the header File, but this deos not help.
-
ThreadHallo, I have the following problem with the Thread: I create the Thread first as SUSPENDED, but it does not start at the expectetd time. First the Program calls this function: ThreadStart(); /////////////////////////////// ThreadStart() { if (m_pSelThread != NULL) { if (::WaitForSingleObject(m_pSelThread->m_hThread, 0) != WAIT_OBJECT_0) return; delete m_pSelThread; m_pSelThread = NULL; } ::WaitForSingleObject(m_SEl_Start_Event, 0); m_SEl_Start_Event.SetEvent (); // CEvent Object CWinThread* m_pSelThread = AfxBeginThread(ThreadFunktion, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); m_pSelThread->m_bAutoDelete = FALSE; m_pSelThread->ResumeThread(); } UINT ThreadFunktion ( LPVOID param ) { if (param == NULL) return -1; DoSomeThing(); return 0; } The Thread does not come to the UINT ThreadFunktion(LPVOID param). Any help would be appriciated.
-
UINT ThreadProc ( LPVOID param )The question is when i pass (this) instead of (hwnd) to the ThreadProc function i get a crash. The question is above.
-
UINT ThreadProc ( LPVOID param )okoay but i have an application crash hier: #ifdef _DEBUG void CTestView::AssertValid() const { CView::AssertValid(); // application crash } #ifndef _WIN32_WCE void CTestView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif #endif
-
UINT ThreadProc(LPVOID param)okay but i got an application crash hier: #ifdef _DEBUG void CTestView::AssertValid() const { CView::AssertValid(); } #ifndef _WIN32_WCE void CTestView::Dump(CDumpContext& dc) const { CView::Dump(dc); } #endif #endif
-
UINT ThreadProc ( LPVOID param )Hello, i tried it the way you said, but it did not work , maybe i did something wrong, hier is the code: void CTestView::ThreadStart(CTestDoc* pDoc, CString strSel) { m_Thread_Sel_Start.SetEvent (); HWND hWnd = GetSafeHwnd(); m_strSelect = strSel; m_pDoc = pDoc;// i need to access the CTestDoc.cpp, i passed pDoc from the CTestDoc.cpp to the CTestView.cpp // and then assigend pDoc to m_pDoc which defined in the top of the CTestView.cpp AfxBeginThread(ThreadProc, this/*hWnd*/, THREAD_PRIORITY_NORMAL);// Hier i passed this to the ThreadProc function } UINT ThreadProc ( LPVOID param ) { (CTestView*)param-> // casting to CTestView did not work? return 0; }