Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Looking for PreciseTimer.zip - Visual C++

Featured Replies

  • Author

Never mind I was able to download now the file.
(attached)!
 

701793291PreciseTimer.zip

  • Author

On the second post it was time measurement, maybe some one will need that.

I've created class PreciseTimer from first post, first link (attached).
And some usage here:

void CAlocLogDlg::OnButton9()
{
    // TODO: Add your control notification handler code here

for (int i=0;i<2000000000;i++)
{
PreciseTimer* pt = new PreciseTimer();

LARGE_INTEGER iStart, iStop;
QueryPerformanceCounter(&iStart);

pt->Wait(5); // is there anything to wait on? ... then wait
QueryPerformanceCounter(&iStop);

long diference = (long)iStop.QuadPart-(long)iStart.QuadPart;

if (diference>5)
{
int no_way = 1;
}


}

}

 

PreciseTimer.zip

  • Author

timeSetEvent https://msdn.microsoft.com/en-us/library/windows/desktop/dd757634(v=vs.85).aspx
suppose to be precise
 

void CALLBACK TimerFunction(UINT wTimerID, UINT msg,
    DWORD dwUser, DWORD dw1, DWORD dw2)
    {

char conv_str[50];
wsprintf(conv_str,"%d", GetTickCount());  // convert number to dec string
InsertStringToList(conv_str);

    }

void CAlocLogDlg::OnButton9()
{
// TODO: Add your control notification handler code here

// https://msdn.microsoft.com/en-us/library/windows/desktop/dd757634%28v=vs.85%29.aspx
MMRESULT m_idEvent = timeSetEvent(1, 0,
        TimerFunction,
        (DWORD)this,
        TIME_PERIODIC);
}

Actually is not precise at all! Still maybe someone will find the solutions posted above useful, but not me!

The best solution I found so far is CreateThread on an infinite loop:
 

DWORD   dwThreadId;
HANDLE hThread = CreateThread(
            NULL,                   // default security attributes
            0,                      // use default stack size  
            MyThreadFunction,       // thread function name
            NULL,          // argument to thread function
            0,                      // use default creation flags
            &dwThreadId);   // returns the thread identifier 

But there is a problem: to many CPU resource are consumed.
I've thinked at something like if the time passed since last value found has a specific value do Sleep(1).

 

  • Author

So here is my solution:
LastTimeValueFound = GetTickCount();
called twice after each variable was readed,

and on the loop I do this:

if (LastTimeValueFound==0||(GetTickCount()-LastTimeValueFound)>100)
{
Sleep(1);
}

CPU usage was once 20% for a short time - when Api logged,
When no Api logged 0% CPU usage,
tracing time 2 minutes for a nasty Asprotect unpackme.
 

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.