Home > Back-end >  DLL create threads, thread calls a function in the class, always appear abnormal memory address
DLL create threads, thread calls a function in the class, always appear abnormal memory address

Time:10-03

Problems such as the topic
This is to create a thread
 
Void __fastcall Tfrm_Main: : tv_RightClick (TObject * Sender)
{
//click on the location of the node information
TTreeNode * tn=tv_Right - & gt; GetNodeAt (pX, pY);
If (tn==NULL)
{
return;
}
Tv_Right - & gt; Selected=tn;
Lbl2 - & gt; Caption=tv_Right - & gt; Selected - & gt; The Text;
//using thread to query SeachDataHD
HANDLE hThread=CreateThread (NULL, 0, SeachDataHD, NULL, 0, NULL);
The CloseHandle (hThread);

For (int I=0; I & lt; This - & gt; ComponentCount; I++)
{
If (this - & gt; The Components [I] - & gt; TSpeedButton ClassNameIs (" "))
{
TSpeedButton * BTN=(TSpeedButton *) this - & gt; The Components [I];
If (BTN - & gt; Name. Pos (" btn_chklst_ "))
{
The delete BTN.
i--;
}
}
}
}

This is a thread function
 DWORD WINAPI SeachDataHD (LPVOID lpParamter) 
{
Frm_Main - & gt; Func_DrawGrid (frm_Main - & gt; Tv_Right - & gt; Selected - & gt; The Text);
}

When running in the thread, called frm_Main - & gt; Tv_Right - & gt; Selected - & gt; The Text, I have to make a mistake, I followed, found frm_Main - & gt; Tv_Right is empty

CodePudding user response:

When it's operating in the thread the VCL interface controls the Synchronize with synchronization method
  • Related