Skip to content

CreateThread 里传入类成员方法,如果调用CreateThread的方法退出过快,线程将不会启动 #3

@fengshangren

Description

@fengshangren

例子:
这样线程将不会被执行。
call_thunk::thunk thunk<cb_type>(obj, &TestClass::fun);
CreateThread ( NULL , 0 , (LPTHREAD_START_ROUTINE )thunk, NULL , 0 , NULL );
return;

这样线程才会成功执行
call_thunk::thunk thunk<cb_type>(obj, &TestClass::fun);
CreateThread ( NULL , 0 , (LPTHREAD_START_ROUTINE )thunk, NULL , 0 , NULL );
Sleep(100);
return;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions