本文介绍了应用程序位于_endthreadex()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我发现很难确定为什么应用程序流在_endthreadex(status)处崩溃;
详细信息粘贴在下面:
-------------------------
SMSrunResponseHandlerThread(int循环,SMS_RUN_DETS * smsRunDetails)
|
V
/* ##在此处使用Win32函数创建线程*/
_beginthreadex()
|
V
无效* sms_response_handler_thread_main(void * arg)
|
V
SMSprocessReceiveMessage()
|
V
/* ## Windows NT线程报告退出状态*/
_endthreadex(状态);

以下代码段中的完整流程:

Hi,
I am finding difficulty to identify why flow of application crashes at _endthreadex(status);
Details are pasted below:
-------------------------
SMSrunResponseHandlerThread (int loop , SMS_RUN_DETS *smsRunDetails)
|
V
/*## Make a thread using Win32 functions here */
_beginthreadex()
|
V
void * sms_response_handler_thread_main(void *arg)
|
V
SMSprocessReceiveMessage()
|
V
/*## Windows NT threads report exit status */
_endthreadex(status);

Complete Flow from below snippet of code:

int SMSrunResponseHandlerThread (int loop , SMS_RUN_DETS *smsRunDetails) /* Calling Function to create Thread _beginThreadex() */
{
void * sms_response_handler_thread_main(void *arg);
int status=SUCCESS;
long thread_tid ;
unsigned *dwTid ;
#ifdef WIN32
HANDLE hThread;
#endif /*## WIN32 */
#ifndef WIN32
pthread_attr_t attr ;
#endif /*## !WIN32 */
#ifdef WIN32
/*## Create a thread , grab the thread id and wait for it */
/*## Make a thread using Win32 functions here */
hThread = (HANDLE)_beginthreadex( NULL
, 0
, (unsigned int (_stdcall *) (void *))sms_response_handler_thread_main
, &smsRunDetails[0]
, 0
, &dwTid
);
smsRunDetails->LocalThreadId1 = hThread ;
#endif /*## WIN32 */
GVprintf("Started ResponseHandler Thread\n");
return (SUCCESS); /* main thread returns */
}

void * sms_response_handler_thread_main(void *arg) /* Function handling the _endThreadex()*/
{
int status=SUCCESS;
SMS_RUN_DETS *localSmsRunDetails=(SMS_RUN_DETS*)arg;
status = SMSprocessReceiveMessage(localSmsRunDetails) ;
if ( status EQ SUCCESS)
{
/*## Add some debug */
GVprintf("SMSprocessReceiveMessage() returned with status%d\n",status); /* Could be able to get control till here */
}
else
{
/*## ResponseHandlerThread not returned successfully */
GVprintf("SMSprocessReceiveMessage() returned with error <%d>\n",status);
}
/*## State whether we succeeded or not in receiving everything */
#ifdef WIN32
/*## Windows NT threads report exit status */
_endthreadex(status); /* Fails @ this call */
#endif /*## WIN32 */
return;
}


预先感谢您的宝贵意见.
问候
raj


Thanks in advance for your valuable inputs.
Regards
raj

推荐答案

jarbangy写道:
jarbangy wrote:

int SMSrunResponseHandlerThread(int循环,SMS_RUN_DETS * smsRunDetails )/*调用函数以创建线程_beginThreadex()*/
{
void * sms_response_handler_thread_main(void * arg);

int SMSrunResponseHandlerThread (int loop , SMS_RUN_DETS *smsRunDetails) /* Calling Function to create Thread _beginThreadex() */
{
void * sms_response_handler_thread_main(void *arg);



上面这行的目的是什么?
:)



What is the purpose of the above line?
:)



这篇关于应用程序位于_endthreadex()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 23:57