CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2015
    Posts
    1

    Timer or Watcher for function result

    Hello!
    I have some value in process memory (not my process).
    I have address of this value and want to execute function or smth else on changing this value.
    I think to use timers but I think they are too slow - low resolution(I read smth from 10 to 50 ms) and uses CPU too much.
    Can you offer me some other solution with not very much cpu usage but with checking variable value nearly 1 to 5 ms.
    Thank you.

  2. #2
    Join Date
    Aug 2014
    Posts
    6

    Re: Timer or Watcher for function result

    You can do it in Threads. Create a void parameterless method

    Code:
             private void MyFunction()
            {
                
                while (yourValueIsNotGood)
                {
                    Thread.Sleep(5);
                }
    
                // here your value is good
                // do your action which you need
            }
    Then call the method in thread

    Code:
                System.Threading.Thread thread = new System.Threading.Thread(MyFunction);
                thread.Start();
                thread.Join();
    
                // you come here when you exit MyFunction() (i.e. your value is good)

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