Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:40:31+00:00 2026-06-02T00:40:31+00:00

I have issue with thread-safe callbacks. void draw_something() { /* draws something */ }

  • 0

I have issue with thread-safe callbacks.

void draw_something() { /* draws something */ }

And the question is, how to call draw_something in main application thread every specify amount of time irrespective of other code(so it would act like C# Timer and fire function in main thread)? Earlier I was using CreateWindow to create(in main thread) auxiliary window which handles messages from SendMessage(which was sent from another timer-thread):

void MainThreadFunction(){
    CreateThread(0, NULL, GoProc, NULL, NULL, NULL);
}

DWORD WINAPI GoProc(LPVOID lpParam){
    while(1){
        SendMessage(auxiliary_window_hWnd, ADDINATIONAL_MESSAGE, 0, 0);
        Sleep(30);
    }
    return 0;
}

So window’s MessageQueue deals safethread calls, but I don’t think if it’s very efficient and elegant way to do it. I know there is better way(maybe boost?) but I don’t know it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:40:33+00:00Added an answer on June 2, 2026 at 12:40 am

    You can use the Windows SetTimer call to get a periodic WM_TIMER message and skip the second thread altogether.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue with a 3rd party DLL, which is NOT thread-safe, but
I have a similar issue like here: http://social.msdn.microsoft.com/forums/en-US/biztalkgeneral/thread/87d5a6ec-04ee-4c6f-8267-f526ee105f0b I have an asp.net web page
While debugging an issue with our system, I have discovered a thread contention that
Possible Duplicate: Are C# arrays thread safe? I have been programming C# for 10
Is the standard Java 1.6 javax.xml.parsers.DocumentBuilder class thread safe? Is it safe to call
I have some unsolved issue with threads. It's my first time doing it. I
I know there are tons of threads regarding this issue but I have not
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We are new to ROR, We have issue in creating Login/Logout process in ROR
Share your ideas please! I have issue to check the folder and convert a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.