Click here to Skip to main content
14,301,769 members

C / C++ / MFC

 
AnswerRe: Change value to a thread Pin
Victor Nijegorodov29-May-19 5:28
memberVictor Nijegorodov29-May-19 5:28 
GeneralRe: Change value to a thread Pin
_Flaviu29-May-19 21:23
member_Flaviu29-May-19 21:23 
GeneralRe: Change value to a thread Pin
Victor Nijegorodov29-May-19 23:01
memberVictor Nijegorodov29-May-19 23:01 
GeneralRe: Change value to a thread Pin
_Flaviu29-May-19 23:23
member_Flaviu29-May-19 23:23 
GeneralRe: Change value to a thread Pin
Victor Nijegorodov30-May-19 0:46
memberVictor Nijegorodov30-May-19 0:46 
GeneralRe: Change value to a thread Pin
_Flaviu29-May-19 23:26
member_Flaviu29-May-19 23:26 
GeneralRe: Change value to a thread Pin
leon de boer30-May-19 1:30
memberleon de boer30-May-19 1:30 
GeneralRe: Change value to a thread Pin
_Flaviu30-May-19 21:08
member_Flaviu30-May-19 21:08 
Here is what I've done:
// TestFileView.h : interface of the CTestFileView class

protected:
	CEvent m_event;
	CString m_sFolder;
	CWinThread* m_pWinThread;

/*static*/UINT CTestFileView::FilesWatchDogThread(LPVOID lpParam)
{
	CTestFileView* pView = (CTestFileView*)lpParam;

	if (NULL == pView->GetSafeHwnd())
		return 1;

	HANDLE hChange = FindFirstChangeNotification(pView->GetFolder(), FALSE,	FILE_NOTIFY_CHANGE_FILE_NAME);

	if (INVALID_HANDLE_VALUE == hChange)
		return 1;

	HANDLE aHandles[2];
	aHandles[0] = hChange;
	aHandles[1] = pView->m_event.m_hObject;

	BOOL bContinue = TRUE;
	while (bContinue)
	{
		DWORD dwResult = WaitForMultipleObjects(2, aHandles, FALSE, INFINITE);
		switch (dwResult)
		{
		case WAIT_OBJECT_0:
			::PostMessage(pView->GetSafeHwnd(), WMU_NOTIFY_FOLDERCHANGED, 0, (LPARAM)0);
			FindNextChangeNotification(hChange);
			break;
		case WAIT_OBJECT_0 + 1:
			bContinue = FALSE;
			break;
		}
	}

	FindCloseChangeNotification(hChange);

	return 0;
}

and
void CTestFileView::StopThread()
{
	m_event.SetEvent();
	WaitForSingleObject(&m_event, INFINITE);
}

and
void CTestFileView::OnEditStartthread()
{
	// TODO: Add your command handler code here

	m_event.ResetEvent();
	m_sFolder.Format(_T("D:\\Tempx\\"));
	m_pWinThread = AfxBeginThread(&CTestFileView::FilesWatchDogThread, (LPVOID)this, THREAD_PRIORITY_NORMAL, CREATE_SUSPENDED, 0, NULL);
}

there is remain one thing to do: to change the folder (m_sFolder) how can I complete this with CreateEvent/SetEvent ?
GeneralRe: Change value to a thread Pin
_Flaviu30-May-19 22:12
member_Flaviu30-May-19 22:12 
GeneralRe: Change value to a thread Pin
Victor Nijegorodov30-May-19 22:39
memberVictor Nijegorodov30-May-19 22:39 
GeneralRe: Change value to a thread Pin
_Flaviu30-May-19 23:57
member_Flaviu30-May-19 23:57 
GeneralRe: Change value to a thread Pin
Victor Nijegorodov31-May-19 0:01
memberVictor Nijegorodov31-May-19 0:01 
QuestionKnow when a files has been copied Pin
_Flaviu28-May-19 5:36
member_Flaviu28-May-19 5:36 
AnswerRe: Know when a files has been copied Pin
Richard MacCutchan28-May-19 5:50
protectorRichard MacCutchan28-May-19 5:50 
AnswerRe: Know when a files has been copied Pin
Victor Nijegorodov28-May-19 20:37
memberVictor Nijegorodov28-May-19 20:37 
AnswerRe: Know when a files has been copied Pin
Dave Kreskowiak31-May-19 2:49
mveDave Kreskowiak31-May-19 2:49 
QuestionI have 3rd party . OCX file. which loads in HTML scripts and do desired work Pin
Gaurav__Kapoor26-May-19 22:12
memberGaurav__Kapoor26-May-19 22:12 
AnswerRe: I have 3rd party . OCX file. which loads in HTML scripts and do desired work Pin
Richard MacCutchan26-May-19 22:35
protectorRichard MacCutchan26-May-19 22:35 
GeneralRe: I have 3rd party . OCX file. which loads in HTML scripts and do desired work Pin
Gaurav__Kapoor27-May-19 2:17
memberGaurav__Kapoor27-May-19 2:17 
GeneralRe: I have 3rd party . OCX file. which loads in HTML scripts and do desired work Pin
Richard MacCutchan27-May-19 3:40
protectorRichard MacCutchan27-May-19 3:40 
QuestionMessage Closed Pin
25-May-19 10:56
professionalMember 1437132725-May-19 10:56 
QuestionClever macro to handle consecutive addresses with built-in static_assert Pin
arnold_w24-May-19 22:54
memberarnold_w24-May-19 22:54 
AnswerRe: Clever macro to handle consecutive addresses with built-in static_assert Pin
Stefan_Lang26-May-19 22:15
memberStefan_Lang26-May-19 22:15 
Question"A rose by any other name would smell as sweet" - so what is the BEST name for "open_dev" function return? Pin
Vaclav_19-May-19 16:54
memberVaclav_19-May-19 16:54 
AnswerRe: "A rose by any other name would smell as sweet" - so what is the BEST name for "open_dev" function return? Pin
Richard MacCutchan19-May-19 21:28
protectorRichard MacCutchan19-May-19 21:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.