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. Managed C++/CLI
  4. How to use timeSetEvent in C++/CLI

How to use timeSetEvent in C++/CLI

Scheduled Pinned Locked Moved Managed C++/CLI
c++helptutorialquestion
4 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.
  • A Offline
    A Offline
    attias gabi
    wrote on last edited by
    #1

    I want to use the timeSetEvent in the C++/CLI for a 1msec timing resolution. I seem to have a problem in the CALLBACK function and when i try to replace it with a delegate i have other problems. Can anyone show me the way to use timeSetEvent with a CALLBACK/Delegate function that actually work?

    G 1 Reply Last reply
    0
    • A attias gabi

      I want to use the timeSetEvent in the C++/CLI for a 1msec timing resolution. I seem to have a problem in the CALLBACK function and when i try to replace it with a delegate i have other problems. Can anyone show me the way to use timeSetEvent with a CALLBACK/Delegate function that actually work?

      G Offline
      G Offline
      guestcat
      wrote on last edited by
      #2

      SampleForm::SampleForm() { InitForm(); } void SampleForm::InitForm() { Timer* timer1; timer1 = new Timer(); timer1->Interval = 3000; // 3 seconds resolution timer1->add_Tick(new EventHandler(this,OnTimer)); timer1->Start(); } void SampleForm::OnTimer(System::Object* obj,System::EventArgs* ea) //declare as static method in .h file { } ^-^ @|@ - redCat

      A 1 Reply Last reply
      0
      • G guestcat

        SampleForm::SampleForm() { InitForm(); } void SampleForm::InitForm() { Timer* timer1; timer1 = new Timer(); timer1->Interval = 3000; // 3 seconds resolution timer1->add_Tick(new EventHandler(this,OnTimer)); timer1->Start(); } void SampleForm::OnTimer(System::Object* obj,System::EventArgs* ea) //declare as static method in .h file { } ^-^ @|@ - redCat

        A Offline
        A Offline
        attias gabi
        wrote on last edited by
        #3

        this is now the timeSetEvent, but the Timer class. The Timer class accuracy is very poor, unlike the timeSetEvent. Can anybody show me how to use it in c++/cli .net 2005?

        O 1 Reply Last reply
        0
        • A attias gabi

          this is now the timeSetEvent, but the Timer class. The Timer class accuracy is very poor, unlike the timeSetEvent. Can anybody show me how to use it in c++/cli .net 2005?

          O Offline
          O Offline
          oshah
          wrote on last edited by
          #4

          First of all, you should note that accuracy is not the same as precision[^]. 10ms is pretty much the most accurate you can get with Win32, without screwing with the operating system metrics or reinstalling the HAL. But anyway, you use timeSetEvent in C++/CLI the same way you use it in Win32.

          #include #pragma comment(lib, "winmm")

          public ref class TimerWrapper
          {
          EventHandle ^eventHandle;
          public:
          TimerWrapper()
          : eventHandle(false, EventResetMode::AutoReset)
          {
          }

          int TimerFunc()
          {
          for( ; ; )
          {
          eventHandle->WaitOne();
          ...
          }
          }

          void UseTimeEvent()
          {
          timeSetEvent(100, 55, reinterpret_cast(
          eventHandle->SafeWaitHandle->DangerousWaitHandle().ToPointer()),
          0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
          ...
          }
          };

          -- modified at 17:31 Saturday 13th May, 2006

          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