Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Run function after X miliseconds
Re: Run function after X miliseconds [message #417966 is a reply to message #417956] Mon, 18 January 2010 12:05 Go to previous messageGo to previous message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma:
General (1 Star)
If i understand you correctly (i think this is multi threading which is new for me) it should be something like this??

HANDLE hThread;

DWORD CALLBACK ThreadProc(void *pArg)
{
    while(playnow)
    {
        DWORD delay;
        delay = PtrToUlong(pArg);
        Sleep(delay);
        FunctionB();
    }
    return 0;
}

void FunctionA()
{
	//Code here; read file containing sounds
	

	FunctionB();
}

void FunctionB()
{
	if(runnow)
	{
		//Pick a random song from the file
		//Play the song

		fsystem->update();
		{
			//Set Volume

			//Get song length (in miliseconds)
		}
                DWORD tid;
                hThread = CreateThread(NULL, 0, ThreadProc, ULongToPtr(songlength), 0, &tid);

	}
//More code; should still run and not only after X miliseconds as Sleep(); would do
}

void FunctionC()
{
     //Close file etc
     CloseHandle(hThread);
}



http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Mon, 18 January 2010 12:27]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hud Help
Next Topic: Islands gmax files?
Goto Forum:
  


Current Time: Thu Nov 28 22:52:52 MST 2024

Total time taken to generate the page: 0.00815 seconds