CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Help Request

  1. #1
    Join Date
    May 2009
    Posts
    2

    Exclamation Help Request

    Hi all,
    how is it possible in c++, that i can call a method after 1 hour
    for example in my case i have huge amount of data,
    i can not check all at once
    so i need to call the functuion automatically after 1 hour

    kindly give me some code example if possible

  2. #2
    Join Date
    Mar 2006
    Location
    Inida
    Posts
    119

    Re: Help Request

    sleep() can be used to wait. Is that what you want?
    Please elaborate your requirement.

    Ganesh

  3. #3
    Join Date
    May 2009
    Posts
    2

    Re: Help Request

    no sleep or wait use too much system resources as inside sleep loops use for delays

    i need to call a function
    called after a specific time

    e . g after 1 hour

  4. #4
    Join Date
    Nov 2006
    Posts
    1,611

    Re: Help Request

    what OS are you using / compiler ?

    both the sleep and wait I'm familiar with use virtually no CPU resources - and no they don't just loop for delay, unless they are incredibly naive implementations on a particular compiler or os.

    There are also timers, but again this is dependent on OS.
    If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).

  5. #5
    Join Date
    Apr 2004
    Posts
    102

    Re: Help Request

    I'm guessing you have large program that is always doing something, and has a main loop that only breaks on some particular user input?

    I'd suggest just look into the data structures and functions in <time.h>.

    Use a variable in your main loop called lastRunTimeFunctionWhatever, initiallized to zero. Check the current system time using <time.h> once per main loop, compare it to that variable, if more than 60 minutes have passed, set the variable to the current system time, then execute your function.

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Help Request

    You could use a timer.

    "in my case i have huge amount of data,
    i can not check all at once
    so i need to call the functuion automatically after 1 hour" doesn't make sense to me. Can you explain the problem in more detail.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured