Solved

Problem with _beginthread and Visual Studio C++.Net

Posted on 2004-03-29
2
1,449 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now