rthreadtest.cpp

来自「Symbian 线程使用 RThread 实现」· C++ 代码 · 共 46 行

CPP
46
字号


#include <e32std.h>
#include <e32cons.h>
#include <e32base.h>


_LIT(KTxtMYThread,"MYThread");

struct TArg
{
	TInt x;
	TInt y;
	TBuf<32> notes;
};


static TInt callback (TAny* aParameters);

GLDEF_C TInt E32Main()				// main function called by E32
    {
    TArg arg;
	arg.x = 0;
	arg.y = 100;
	arg.notes.Copy(_L("hell!"));

	const TInt KHeapSize = 0x800 ;
	
	RThread thread ;
	TRequestStatus iStatus;
  	TInt result = thread.Create(KTxtMYThread,(TThreadFunction)callback, KDefaultStackSize,
  								KMinHeapSize, KHeapSize, &arg, EOwnerThread) ;
  	User::LeaveIfError(result) ;
	thread.Resume();
	thread.Close();

	return 0;										// and return
    }

static TInt callback (TAny* aParameters) 
{
	TArg * arg = (TArg *)aParameters;
	User::InfoPrint(arg->notes);

	return 0;
}

⌨️ 快捷键说明

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