VC++ multi-threaded packaging class (with source code)

VC++ commonly used functions package code a series of articles and source code (advertisement, haha, look at the series and then decide whether to subscribe)

https://blog.csdn.net/kaizi318/article/details/108846326

The source code demo has been uploaded to the Baidu network disk: permanent effective, the code encapsulates the creation of threads, suspending threads, resuming threads, and waiting for threads to exit

, Set priority, stop thread and other functions

Go directly to the code to see the header file of the package class

#include <windows.h>

//Callback function pointer
typedef void (*THREAD_ROUTINE)(void *);

class CWorkThread  
{
public:
    CWorkThread();
    virtual ~CWorkThread();

public:
    // Create thread
    HRESULT Create(THREAD_ROUTINE pfn, void *pArg);

    // Stop the thread
    void Stop();

    // Suspend the thread
    void Suspend();

    // Resume thread
    void Resume();

    // Wait for the thread to exit
    void Join();

    // Get the priority of the thread
    int SetPriority(int nPriority);

    // Set priority
    int GetPriority();

    // Thread function
    static unsigned long __stdcall T

Guess you like

Origin blog.csdn.net/kaizi318/article/details/108880421