How to wrap a thread?
Hello,
I can't seem to solve this problem for hours
My original code,
#pragma once
#include <string>
#include <afxwin.h>
#include <process.h>
using namespace std;
enum { MANAGE_DISPLAY = 0, };
class Thread_Factory
{
// typedef UINT ((AFX_THREADPROC) MyFuncPtrType)(LPVOID arg);
public:
Thread_Factory(void);
~Thread_Factory(void);
public:
void StartThread(int DelegateNo);
};
And
#include <process.h>
#include "StdAfx.h"
#include ".\thread_factory.h"
UINT Manage_Dis(void *arg);
Thread_Factory::Thread_Factory(void)
{
}
Thread_Factory::~Thread_Factory(void)
{
}
void Thread_Factory::StartThread(int DelegateNo)
{
switch (DelegateNo)
{
case MANAGE_DISPLAY:
//dele = (AFX_THREADPROC)Manage_Dis;
AfxBeginThread(Manage_Dis, (LPVOID)0, NULL);
break;
default:
;
}
}
UINT Manage_Dis(LPVOID arg)
{
return 0;
}
And this works properly, but when I want to wrap it into a class
like this
#pragma once
#include <string>
#include <afxwin.h>
#include <process.h>
using namespace std;
enum { MANAGE_DISPLAY = 0, };
class Thread_Factory
{
// typedef UINT ((AFX_THREADPROC) MyFuncPtrType)(LPVOID arg);
public:
Thread_Factory(void);
~Thread_Factory(void);
public:
void StartThread(int DelegateNo);
UINT Manage_Dis(LPVOID arg);
//static UINT ((AFX_THREADPROC)Manage_Dis)(LPVOID);
// AFX_THREADPROC Dele;
};
And
#include <process.h>
#include "StdAfx.h"
#include ".\thread_factory.h"
//UINT Manage_Dis(void *arg);
Thread_Factory::Thread_Factory(void)
{
}
Thread_Factory::~Thread_Factory(void)
{
}
void Thread_Factory::StartThread(int DelegateNo)
{
switch (DelegateNo)
{
case MANAGE_DISPLAY:
//dele = (AFX_THREADPROC)Manage_Dis;
AfxBeginThread((AFX_THREADPROC)Thread_Factory::Manage_Dis, (LPVOID)0, NULL);
break;
default:
;
}
}
UINT Thread_Factory::Manage_Dis(LPVOID arg)
{
return 0;
}
I get this:
c:\Documents and Settings\Jacky\My Documents\Visual Studio
Projects\ComDemo\Thread_Factory.cpp(23): error C2440: 'type cast' : cannot
convert from 'overloaded-function' to 'AFX_THREADPROC'
Is there anyway I can work around this?
Thanks
Jack