Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need application working for timer basis

Need application working for timer basis

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialdiscussion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Game point
    wrote on last edited by
    #1

    Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K

    :~ Failure is Success If we learn from it!!:~

    C L 2 Replies Last reply
    0
    • G Game point

      Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K

      :~ Failure is Success If we learn from it!!:~

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Cannot you just use a timer (see"Using Timers"[^]) for the purpose? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      1 Reply Last reply
      0
      • G Game point

        Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K

        :~ Failure is Success If we learn from it!!:~

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        I will give you only some leads and not spoon feed you. What you have to do is something like this.

        HANDLE hEvent;

        long FunctionThread(void*)
        {
        while(true)
        {
        WaitForSingleObject(hEvent, NULL);
        // do your job
        // break out of this loop as necessary
        }
        return 0;
        }

        long TimerCheckThread(void*)
        {
        while(true)
        {
        if(timeout)
        {
        SetEvent(hEvent);
        }
        // break out of this loop as necessary
        }
        return 0;
        }

        void Setup()
        {
        // create the event
        hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

        // start both the threads using CreateThread(...)
        

        }

        Event is something that allows synchronization of threads. WaitForSingleObject(...) function waits until the event is set and won't consume valuable CPU cycles. So, that job is going to start only after the time out has occurred. Read more about the terms that you encounter here and after you understand, you can easily build on this example.

        ...byte till it megahertz...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups