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 6581221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:07:32+00:00 2026-05-25T16:07:32+00:00

I wanted to do something using multi-threading and all the stuff encapsulated in function

  • 0

I wanted to do something using multi-threading and all the stuff encapsulated in function foo .

filterThread = _beginthread (foo, 0,NULL) ;

and I wanted to let foo return value:

int foo()
{
    return iRet;
}

but the prototype of _beginthread _CRTIMP uintptr_t __cdecl _beginthread (_In_ void (__cdecl * _StartAddress) (void *),
_In_ unsigned _StackSize, _In_opt_ void * _ArgList)
shows that foo must be void which means cannot return value .
Is there any way else i can do to let foo return value?

  • 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-05-25T16:07:33+00:00Added an answer on May 25, 2026 at 4:07 pm

    To get the return value aka exit code of thread:

    Call this function on thread’s handle after it has finished,

    DWORD ExitCode;
    GetExitCodeThread(hThread, &ExitCode);
    

    As an example, consider using _beginthreadex instead,

    unsigned __stdcall foo( void* pArguments )
    {
        _endthreadex( 0 );
        return 0;
    } 
    
    int main()
    { 
        HANDLE hThread;
        unsigned threadID;
    
        hThread = (HANDLE)_beginthreadex( NULL, 0, foo, NULL, 0, &threadID );
    
        WaitForSingleObject( hThread, INFINITE );
    
        CloseHandle( hThread );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to print something using printf() function in C, without including stdio.h, so
If I wanted to represent states or options or something similar using binary flags
I wanted to write something basic in assembly under Windows. I'm using NASM, but
If I wanted to do something like this: collection.each do |i| return nil if
I wanted to do something like this: <asp:Label ID=lblMyLabel onclick=lblMyLabel_Click runat=server>My Label</asp:Label> I know
Basically I wanted to do something like git push mybranch to repo1, repo2, repo3
I have been bitten by something unexpected recently. I wanted to make something like
This is something that's I've wanted to know recently, mostly out of curiousity. I'm
I wanted to make Map of Collections in Java, so I can make something
After some time I wanted to update my git repo, and then something went

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.