I need a OnTimer() function in a "Blank Plugin" Project, what is the best way to do that ?
Inviato Fri 08 Aug 08 @ 2:13 am
What do you need to do in that timer routine? Would it not be best to use an API call to set up a timer with a callback function attached - assuming it's not any DirectX drawing operation of course.
Inviato Fri 08 Aug 08 @ 7:33 am
It should "monitor" VDJ via GetInfo() and then when changes accours like a new song loaded send it to a LCD display or a Named Pipe connection. So no DirectX etc.
I am going to use this for 3 different things.
1 - Generic VDJ to .NET communications lib. Via Named pipes Full Duplex. This will not just "monitor".
2 - Extra LCD to my DMC1/DAC2 mappers. To show extra info.
3 - Generic LCD for controllers without it. Like DJC, RMX etc.
I am going to use this for 3 different things.
1 - Generic VDJ to .NET communications lib. Via Named pipes Full Duplex. This will not just "monitor".
2 - Extra LCD to my DMC1/DAC2 mappers. To show extra info.
3 - Generic LCD for controllers without it. Like DJC, RMX etc.
Inviato Fri 08 Aug 08 @ 7:54 am
You have 2 ways:
* a Timer:
// Declaration
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
UINT uTimer;
DWORD speed; // (in ms)
// Constructor
uTimer = (UINT) SetTimer(NULL, NULL, speed, (TIMERPROC)TimerProc);
// Desctructor
KillTimer(NULL, uTimer);
// Your function
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD)
{
// write here to do each 'speed' ms
}
* a new Thread:
==> the easy way:
//Declaration
HANDLE hThread;
DWORD dwThreadId;
DWORD speed; // (in ms)
DWORD WINAPI NewThread( void* lpParameter );
// Constructor
hThread=CreateThread(NULL, 0, NewThread, lpParameter, NULL, &dwThreadId);
// Destructor
DWORD dwRes=WaitForSingleObject( hThread, INFINITE );
or
( BOOL bRes=TerminateThread(hThread, 0); )
// The function
DWORD WINAPI NewThread( void* lpParameter )
{
// write here to do each 'speed' ms
Sleep(speed);
}
==> the advanced and safer way
use an event or other ways
* a Timer:
// Declaration
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
UINT uTimer;
DWORD speed; // (in ms)
// Constructor
uTimer = (UINT) SetTimer(NULL, NULL, speed, (TIMERPROC)TimerProc);
// Desctructor
KillTimer(NULL, uTimer);
// Your function
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD)
{
// write here to do each 'speed' ms
}
* a new Thread:
==> the easy way:
//Declaration
HANDLE hThread;
DWORD dwThreadId;
DWORD speed; // (in ms)
DWORD WINAPI NewThread( void* lpParameter );
// Constructor
hThread=CreateThread(NULL, 0, NewThread, lpParameter, NULL, &dwThreadId);
// Destructor
DWORD dwRes=WaitForSingleObject( hThread, INFINITE );
or
( BOOL bRes=TerminateThread(hThread, 0); )
// The function
DWORD WINAPI NewThread( void* lpParameter )
{
// write here to do each 'speed' ms
Sleep(speed);
}
==> the advanced and safer way
use an event or other ways
Inviato Fri 08 Aug 08 @ 10:42 am
Thanks for the info .
Inviato Sat 09 Aug 08 @ 2:12 am