CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Location
    Turkey
    Posts
    173

    is timer thread-safe?

    Let's say we have 3 timers started by 'SetTimer' on a single window. So we have 3 different static TIMERPROC function.

    i.e.

    CMyWindow::OnInitialUpdate()
    {
    ...
    SetTimer( 1200, 500, (TIMERPROC)Function1 );
    SetTimer( 1300, 500, (TIMERPROC)Function2 );
    SetTimer( 1400, 500, (TIMERPROC)Function3 );
    ...
    }

    //static
    UINT CMyWindow::Function1( ... )
    {
    ...
    }

    and others...

    Is there a possibilty of calling any two of Function1, Function2 and Function3 at the same time? Are they processed by a single thread or by three different threads?

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    A timer created using SetTimer() is thread-safe. The main thread can only process one line of code at any given time.

    Kuphryn

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