Einzelnen Beitrag anzeigen
Ungelesen 18.11.10, 20:16   #6
Nava001
Anfänger
 
Registriert seit: Jul 2009
Beiträge: 15
Bedankt: 2
Nava001 ist noch neu hier! | 0 Respekt Punkte
Standard

Du musst die Uhrzeit überwachen und zwar in einer Endlosschleife.
Aber überprüfe die Uhrzeit nur alle z.B. 30 Sekunden.

Code:
The unix functions sleep and usleep are not available in their simple form. The windows function Sleep() may be used (note the capital S) but it introduces complexities. It requires two heavyweight include files that define a lot of global names, and the chances for a name clash are high. Unfortunately I do not know of any other way of making a pause in processing without using a tight loop that keeps the CPU fully occupied. 


   void Sleep(int ms)
      include: <windows.h>
      include: <winbase.h>
      The parameter is the number of milliseconds to sleep, and is actually
      declared as a DWORD, but that is functionally equivalent to int.
      This function actually causes the calling Thread to sleep for the
      specififed time, not the whole process. The sleep time is fairly accurate, and
      is not affected by differences in CPU speed.
         The following is the example that was provided for _getch() and _kbhit(), but
      in a more friednly and efficient form:

          while (1)
          { if (_kbhit())
            { int x=_getch();
              if (x>='a' && x<='z') x-=32;
              else if (x>='A' && x<='Z') x+=32;
              printf("[%c]", x); }
            else
            { Sleep(1000);
              printf("."); } }
Nava001 ist offline   Mit Zitat antworten