Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with _beginthread and Visual Studio C++.Net

Posted on 2004-03-29
2
Medium Priority
?
1,467 Views
Last Modified: 2008-02-01
I have just started using the Visual Studio C++.NET.  I used to use Visual Age by IBM.  My program uses mutitasking and I can't get the _beginthread correct.

My command is "_beginthread(update_db_thread,0,(void *)thread_index);"  where update_db_thread is the name of the thread and thread_index is an integer i am passing to the thread.  

I get the following error "c:\C++\MAIS704\MAIS704.cpp(944): error C2664: '_beginthread' : cannot convert parameter 1 from 'void (int)' to 'void (__cdecl *)(void *)'.  
Do I have to cast the name or am I doing something else wrong.  ???  If so how does the cast statement look.
0
Comment
Question by:larryH
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 10707812
The prototype of update_db_thread() has to be

void update_db_thread(void *pParam);

You can cast the pParam to an integer if you want.

void update_db_thread(void *pParam)
{
    int nParam = (int)pParam;
}
0
 

Author Comment

by:larryH
ID: 10708087
Thank You  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question