⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_threadmanager.cpp

📁 一个完整进行显示和管理的例子
💻 CPP
字号:
#include "StdCgi.h"
#include <conio.h>
//#include <process.h>
#include "..\ThreadManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//////////////////////////////////////////////////////////////////////////////
// Global varaiabales for this module

//////////////////////////////////////////////////////////////////////////////
// Helper declarations for this module

UINT APIPRIVATE A_Thread_Function( PVOID pvThreadData )
{
	delete [] PCHAR( pvThreadData );
	for ( int iStep=0; iStep<1000000; iStep++ )
		;
	return( 1 );
}

//////////////////////////////////////////////////////////////////////////////
//
UINT APIPRIVATE Another_Thread_Function( PVOID pvThreadData )
{
	delete [] PCHAR( pvThreadData );
	CINT ciThreads = 10;

	for ( int iTest=0; iTest<ciThreads; iTest++ )
	{	// Check which load method to use
		char *pszData = new char[20];
		CThreadManager ThreadManager( &A_Thread_Function, (LPVOID)pszData );
		VERIFY_RETURN( ThreadManager.RunThread() );
	}
	return( 1 );
}

//////////////////////////////////////////////////////////////////////////////
//
void main( )
{
	ONLY_IN_DEBUG( afxDump.SetDepth( 1 ) );
	{	// Perform initialisation of the thread Manager
		char *pszData = new char[20];
		CThreadManager ThreadManager( &A_Thread_Function, (LPVOID)pszData );
		ThreadManager.RunThread();
	}
	CINT ciThreadFunctions = 10;

	for ( int iTest=0; iTest<ciThreadFunctions; iTest++ )
	{	// Check which load method to use
		char *pszData = new char[20];
		CThreadManager ThreadManager( &Another_Thread_Function, (LPVOID)pszData );
		VERIFY_RETURN( ThreadManager.RunThread() );
	}
//	Sleep( 1000 );
	// After this line the number of threads should be returned to the start point
//	StopThreadManager();
	puts( "Press any key to exit" );
	getche();
}		// End Main

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -