How to create a time counter without using Sleep()?

I want to create a time counter that would count from 120 minutes and down. I thought about using Sleep() but I have found out that Sleep() is not accurate (so maybe the countdown would take 122 minutes instead of 120 minutes!). What other alternatives do
I have?
Note that I want to count 1 second at a time, because I want to show the countdown progress to the user in seconds.

The next experiment still uses Sleep and waits for approximately 12 seconds, displaying the time each second. However it is probably too overcomplicated compared to time polling:
const
int SECONDS_TO_WAIT =
12;
ULARGE_INTEGER ul_end;
FILETIME ft;
GetSystemTimeAsFileTime( &ft );
ul_end.LowPart = ft.dwLowDateTime;
ul_end.HighPart = ft.dwHighDateTime;
ul_end.QuadPart += 10LL *
1000 *
1000 * SECONDS_TO_WAIT;
for( ;; )
FILETIME ft;
GetSystemTimeAsFileTime( &ft );
ULARGE_INTEGER ul;
ul.LowPart = ft.dwLowDateTime;
ul.HighPart = ft.dwHighDateTime;
if( ul.QuadPart >= ul_end.QuadPart )
break;
SYSTEMTIME st;
FileTimeToSystemTime( &ft, &st );
Sleep( 1000 - st.wMilliseconds );
GetSystemTime( &st );
if( st.wMilliseconds >
500 )
FILETIME ft;
SystemTimeToFileTime( &st, &ft );
ULARGE_INTEGER ul;
ul.LowPart = ft.dwLowDateTime;
ul.HighPart = ft.dwHighDateTime;
ul.QuadPart += 10LL *
1000 *
1000;
ft.dwLowDateTime = ul.LowPart;
ft.dwHighDateTime = ul.HighPart;
FileTimeToSystemTime( &ft, &st );
// show the time
SystemTimeToTzSpecificLocalTime( NULL, &st, &st );
printf( "%02i:%02i:%02i\n", st.wHour, st.wMinute, st.wSecond

Similar Messages

  • How to create an apple id without using credit card

    how to create an apple id without using credit card.. i have recently purchased apple iphone 3gs bt unable to get apps because of giving credit card info which i dnt hav.. so plz tel me some way to process..

    To get the none option, sign out of anything apple you're signed into. Go to the app store and try to download a free app, any free app. Instead of signing in, take the option to to make a new apple ID. Then go through the steps to make the ID and you'll see the 'none' option.

  • How to create a viewobject dynamically without using wizard

    Hi,
    I am Using jDEV 11G, i need to create a viewobject dynamically without using wizard, without binding from any entity.
    Actually my intention is to make a grid like in .Net, when a user want to create a new row in RichTable without using DB.
    just like shopping cart.
    i have done thsi code:
    ViewObjectImpl view=new ViewObjectImpl();
    view.addDynamicAttributeWithType("Att1","String",null);
    view.addDynamicAttributeWithType("Att2","String",null);
    view.addDynamicAttributeWithType("Att2","String",null);
    Row rw=view.createRow();
    rw.setAttribute("Att1","First1");
    rw.setAttribute("Att2","First2");
    rw.setAttribute("Att2","First3");
    view.insertRow(rw);
    I have a RichTable , i need bind this viewobject into that.
    Edited by: vipin k raghav on Mar 10, 2009 11:39 PM

    Hi Vipin,
    You can create the view object with rows populated at run time.
    [http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/bcquerying.htm#CEGCGFCA]
    For reference of how to create an empty rwo at run time on button click
    [http://kohlivikram.blogspot.com/2008/10/add-new-row-in-adf-table-on-button.html]
    ~Vikram

  • How to create inspection lot manually without using QA01 Transaction code?

    Hi,
    Please anybody give procedure for creating Inspection Lot Manually without using Transaction Code QA01

    Hello, Srinivas,
    If you want another T code only then you can try QA01A.
    or you can create a Physical Sample with QPR1 and then click on the button there to create inspection lot. To create inspection lot for that Physical sample (you will able to see that button only after releasing the sample) Or you can use QPR5.
    But let me know the reason why you want T code other than QA01.
    Regards,
    Shyamal

  • How to create "Filter- Render- Clouds" without using the filter....?

    Hi,
    I'm trying to do something and it would take forever to explain. So I'll simplify my question, and I hope you guys know how to do this.
    I want to create the same effects the filter called "Clouds" creates. This filter is found in the "Render" sub-menu under "Filter".
    I've tried creating Noise, and then bluring it. I've tried painting blobs of white on black, blurring it, then using the "Sponge" filter with no luck.
    So, again, a way to create the same effect using any method besides "Clouds" filter... to make it look near or very near to what the "Clouds" filter creates, without using that particular filter. I've spent about 3 hours attempting this with no luck.
    Thanks so much!

    Actually, it is not that hard to create clouds from scratch.  The secret is to look at lots of real clouds to see how they work.   But you can create some pretty good clouds with the render Clouds filter.  Start with a canvas way bigger than your target image, and fill with the Render Clouds filter.  Then use Free Transform to flatten and reshape it.  Also use FT to add LOTS of perspective if you want to get that UltraWide lens look.
    Where Render Clouds and FT falls short is that real clouds are layered, and surprisingly dark on their shadow side.  But it is still doable with Dodge Burn and multiple cloud layers.
    Not quite the sme thing, but I saw a really cool tutorial using clouds on Planet Photoshop a while back. Definitely worth a look at.
    http://www.planetphotoshop.com/creating-exploding-brushes.html

  • How to create logical standby database without using Oracle Grid Control

    Hi All,
    I want to create Logical standby database on 11gr2 on RHEL 5 without using oracle Grid Control.
    I already have a primary database as well as physical standby database.
    What i want to create a logical standby database as well on the same machine where physical standby database is running.
    So anyone of you help me out to do that
    Thanks in advance

    Hi,
    Creating a Logical Standby Database
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ls.htm#SBYDB00300
    Regards,
    Tom

  • How to create a time counter

    Hello expertsl,
    I have a new challenge on board.
    I have a form that is automatically popped up. Now on the form, i need to insert a timer that as soon as it pops out, the timer starts and then i have to enter some data in the form and as soon as i press the save button, the timer records the time count and then stores it in a table.
    Any suggestion are the most welcome...
    Thank you

    As Hoek said, this is not a Forms forum.
    However, the problem is not really unique to Forms and a timer itself is not needed.
    A timer is a kernel object that fires at specific intervals and each time around executes a callback routine. This allows one to update or process at specific intervals.
    You do not need a timer as you are interested in time elapsed - which means that on the creation of the form you need to get the current time. When the save button is clicked you again get the current time. The data that you are interested in is the time difference between these two.
    Remember that timers are expensive objects to create ito kernel resources. Some operating systems limit the total number of timers that can be created. In general, it is not a good idea to create a timer unless it is the best technical solution for the problem. And you do not need a timer determine a time elapse. You simply need code in the constructor of the form and code in the save events of the form. Nothing more.

  • How to create a time event without having user interface freeze

    Hi,
    I am new to labwindows and i am trying to create a time event where every hour for 24 hours i want my program to write somethign in excel. 
    I tried using function Delay and SyncWait and those functions freezes up the user interface.
    Any tips/help will be appreciated.
    Thank You
    Solved!
    Go to Solution.

    Many, if not most, CVI developers wind up implementing a delay function for themselves that periodically, during the delay, wakes up and processes events so that the GUI isn't frozen.
    The idea is to break the wait or delay up into pieces, and process system events in between each piece.
    A timer works too, you can try the async timer that Wolfgang mentioned, it runs a bit better and on a separate thread, so it lets you do what you normally would with the main thread and the GUI, yet still get timer function.   If you use a smart delay, you still wind up doing nothing a great deal of the time, and events are only processed periodically.

  • How to create an itunes account without using a credit card but there is no option for "none"

    itouch 4g

    I recently had to do this... but I figured it out.
    http://docs.info.apple.com/article.html?artnum=301961
    also,
    http://tinyurl.com/29bjce
    You may be able to use the account you are using to post on this forum
    Message was edited by: dddeeefff

  • CREATE XML PUBLISHER REPORT WITHOUT USING RDF

    Hi Every one ,
    Can anybody share his/her expertise on following issue ?
    "How to create XML Publisher Report without using RDF?"
    Your help is appreciated.

    Hi Swapnesh
    YOu do not need to create the XDODTEXE, its seeded for you. You need to do the following:
    1. Create and test the data template
    2. Load the data template to the template manager against a data definition
    3. Create a concurrent program definition that uses the XDODTEXE as its executable
    4. Create parameters (if required) for the CP and DT that match in name
    You're done
    Regards
    Tim

  • How can i create an apple id without using a visa or credit card

    how can i create an apple id without using a visa or credit card

    Follow the directions here, EXACTLY:
    http://support.apple.com/kb/ht2534

  • How can I create a new entry without using LOV for foreign keys.

    Referring to TUHRA sample application based on HR database schema. JDeveloper 10.1.3.0.4
    How can I create a new employee without using LOV for the foreign key "job_id".
    On the first page I would like to choose the job_title from adf read-only table.
    After clicking on the "create new employee button" a creation form appears in which the job_id field is set with previous selection.
    Regards M.Winkler
    Edited by: user3541283 on 06.10.2008 03:44
    Edited by: user3541283 on 06.10.2008 03:50

    Hi,
    usually the foreign key is only set if the VO you select is dependent from a master. If e.g. you have DepartmentsVO1 that has an EmployeeVO3 as its nested VO, then creating a new instance of employees automatically add the foreign key. If you add EmployeesVO1, which is not dependent to DepartmensVO1, then the foreign key is not set. So if this is the case in THURA (keep in mind that this is not an Oracle demo but a sample used in a book about ADF) then all you need is to take the independent VO when building the new employee form.
    Frank

  • How to create a background job without a variant ?

    How to create a background job without a variant ?

    Hi,
    Go to se38.. specify the program name and execute Or use Tcode
    On the selection screen specify the variant...
    Then from the menu options choose program->excute in background...
    In this way we can crate a backgroup job with out crateing any varinat for the report...
    Satya.

  • How to create physical standby database without dataguard

    Hi,
    Can anyone please help me how to create Physical Standby Database without dataguard. As i am using Oracle 10.2.0.1 Standard Edition for production databases.
    Please find the specifications of my server :
    Database : Oracle 10.2.0.1(Standard Edition)
    Server : Linux 4.0(32 bit machine)
    As we know that Dataguard cannot be created in Standard Edition as we dont have that option in this edition. So please help me how to create the physical standby database.
    Thanks in advance.
    Regards,
    Farooq

    Hello,
    I hope this link helps you out...
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/rcmbackp.htm
    http://www.dbasupport.com/oracle/ora10g/manual_standby.shtml
    Thanks & Regards
    Pratik Lakhpatwala
    Jr Oracle DBA
    Edited by: Pratik.L on Dec 31, 2009 12:03 PM

  • How to create  hierarchy on bi7 by using dtp

    how to create  hierarchy on bi7 by using dtp

    Hi Deba,
    Procedure to create Hierarchies:
    1.      In the Data Warehousing Workbench under Modeling, choose the InfoObject tree.
    2.      If you have assigned the hierarchy basic characteristic to an InfoObject catalog, select the corresponding InfoObject catalog for an InfoArea.
    If the hierarchy basic characteristic does not belong to an InfoObject catalog, choose the InfoArea Non-Assigned Nodes and the InfoObject Catalog Non-Assigned Characteristics.
    3.      Select the characteristic for which you want to create a hierarchy and choose Create Hierarchy from the context menu. The Create Hierarchy dialog box appears. The InfoObject name appears by default.
    4.      Enter a hierarchy name and description (short, medium, long). Other fields may be displayed, depending on which hierarchy properties were selected for the hierarchy basic characteristics
    Fields used to enter the Validity (valid to, valid from) for the hierarchy property Total Hierarchy Time-Dependent
    Fields used to specify the Hierarchy Version for the hierarchy property Hierarchies Version-Dependent.
    5.      Confirm your entries. The Maintain Hierarchy screen appears. You can define the structure of a hierarchy here.
    6.      To create a hierarchy node, you first need to choose an insertion mode:  Insert as First Child or   Insert As Next Neighbor (see Hierarchy Editing Functions).
    7.      Choose the type of node you want to create: Text Node, Characteristic Node, <Hierarchy Basic Characteristic Node> or Interval (see Hierarchy Nodes)
    8.      Repeat this procedure until the hierarchy structure has been set. For more information, see Modeling Nodes and Leaves.
    A hierarchy can contain 50,000-100,000 leaves at most. If your hierarchy is larger, you should insert a level that is used as a navigation attribute or preferably as a separate characteristic in the dimension table.
    9.      You can use Level Maintenance and Hierarchy Attributes to set how the hierarchy is to be displayed and processed in reporting (see Level Maintenance and Hierarchy Attributes).
    10.      Save the hierarchy.
    11.      Activate the hierarchy. See Editing Hierarchies.
    For more info
    [http://help.sap.com/saphelp_nw70/helpdata/EN/80/1a6736e07211d2acb80000e829fbfe/content.htm]
    [http://help.sap.com/saphelp_nw70/helpdata/EN/e6/951d102a6c11d5b2e40050da4c74dc/content.htm]
    Regards,
    Rajkandula

Maybe you are looking for

  • Creating PDF from Word loses text

    Hi, using Acrobat 9.0 Pro, and creating a PDF with the toolbar icon in MS Word 2003. Occasionally, the newly created PDF will be missing two lines of text at the top of the 2nd page. This happens on the one document consistently, which is used as a t

  • URL Links in Guided Procedures appear in large fonts.

    Hello Gurus, While navigating through a guided procedure application I had developed using Web Dynpro I noticed that all the URL Links appeared in a large font. I tried switching the font size to small but this made no difference in the views. Then I

  • IDEA: Junk Mail Button on WebMail Sync with Mail.app

    Feature Request to Apple / .Mac JUNK MAIL BUTTON ON WEBMAIL Recently I have had to log into the .Mac website to read my email via the WebMail page. I usually read my email on my Powerbook with the Apple Mail app. I was astonished to see how much spam

  • Hide User Accounts on Windows 7 Logon

    Hi I Just Installed Windows 7 and Want to hide other user accounts on Windows 7 64 and actually Windows Vista so the only Account showing is mine how do I do This, am I right in thinking it has to be done through the registry; HKEY_LOCAL_MACHINE \SOF

  • How to decrease jpeg size without losing quality?

    i am creating different size of images reading with bufferedimage then redrawing image with different sizes... I have created a 500*375 -192 kb picture from original with my code then uploaded it to flickr....it produced 500*375 picture with 133 kb..