class A
{
public:
A();
virtual ~A();
public:
void startthread();
vitual OnData(){};
private:
static DWORD WINAPI threadproc(LPVOID lpArg);
};class B : public A
{
virtual OnData();
}void A::startthread()
{
DWORD dwThreadID;
createthread(NULL, 0, threadproc, this, 0, &dwThreadID);
}DWORD WINAPI A::threadproc(LPVOID lpArg)
{
A* _this = (A*)lpArg; MSG msg;
int sum = 0;
while(GetMessage(MSG, NULL, 0, 0))
{
sum++;
_this->OnData(); }
return 0;
}void B::OnData()
{
// 这里有时候能进来,有时候则不能
static int count = 0;
count++;
}为什么 threadproc 中 sum 的值与 B::OnData 中 count 的值不一样?急急!!
{
public:
A();
virtual ~A();
public:
void startthread();
vitual OnData(){};
private:
static DWORD WINAPI threadproc(LPVOID lpArg);
};class B : public A
{
virtual OnData();
}void A::startthread()
{
DWORD dwThreadID;
createthread(NULL, 0, threadproc, this, 0, &dwThreadID);
}DWORD WINAPI A::threadproc(LPVOID lpArg)
{
A* _this = (A*)lpArg; MSG msg;
int sum = 0;
while(GetMessage(MSG, NULL, 0, 0))
{
sum++;
_this->OnData(); }
return 0;
}void B::OnData()
{
// 这里有时候能进来,有时候则不能
static int count = 0;
count++;
}为什么 threadproc 中 sum 的值与 B::OnData 中 count 的值不一样?急急!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货