Error given :IDE : MS Visual Studio 2005Error 1 error C3867: 'GenericThread::ThreadProc': function call missing argument list; use '&GenericThread::ThreadProc' to create a pointer to member ...\GenericThread\GenericThread.cpp 19
GenericThread.hGenericThread.cppCode:#pragma once #include <Windows.h> class GenericThread { public: GenericThread(); ~GenericThread(); // Create and run the thread void Start(LPVOID lpParameter, int nPriority = 0, bool create_suspended = false, SIZE_T stack_size = 0, bool reserve_stack = false); // This member function will run when you call StartThread() DWORD WINAPI ThreadProc(LPVOID lpParameter); // -15 : lowest; +15 : highest void SetPriority(int nPriority); // Get currently assigned priority level int GetPriority(); // Get thread status bool IsRunning(); // Pause execution void Suspend(); // Resume execution void Resume(); // Terminate execution void Terminate(); // Return thread handle HANDLE GetHandle(); private: // Handle to the thread HANDLE m_hThread; // The thread id assigned by Windows, there is no use for now LPDWORD m_lpdwThreadID; // You can use this property to signal the ThreadProc() to prepare for termination bool m_bExiting; // Thread status bool m_bRunning; };Code:#include "GenericThread.h" GenericThread::GenericThread() { m_bExiting = false; m_bRunning = false; } GenericThread::~GenericThread() { if (m_bRunning) CloseHandle(m_hThread); } void GenericThread::Start(LPVOID lpParameter, int nPriority /*= 0*/, bool create_suspended /*= false*/, SIZE_T stack_size /*= 0*/, bool reserve_stack /*= false*/) { DWORD dwCreationFlags = 0; if (create_suspended) dwCreationFlags |= CREATE_SUSPENDED; if (reserve_stack) dwCreationFlags |= STACK_SIZE_PARAM_IS_A_RESERVATION; m_hThread = CreateThread(NULL, stack_size, ThreadProc, lpParameter, dwCreationFlags, m_lpdwThreadID); // ERROR GIVEN ON THIS LINE SetPriority(nPriority); m_bRunning = true; } DWORD WINAPI GenericThread::ThreadProc(LPVOID lpParameter) { while (true) Sleep(60000); return 0; } void GenericThread::SetPriority(int nPriority) { SetThreadPriority(m_hThread, nPriority); } int GenericThread::GetPriority() { return GetThreadPriority(m_hThread); } bool GenericThread::IsRunning() { return m_bRunning; } void GenericThread::Suspend() { SuspendThread(m_hThread); } void GenericThread::Resume() { ResumeThread(m_hThread); } void GenericThread::Terminate() { CloseHandle(m_hThread); m_bRunning = false; } HANDLE GenericThread::GetHandle() { return m_hThread; }




Reply With Quote
