BCB中TCriticalSection运行出错?
在主线程中定义全局变量extern TCriticalSection *pLockXY; extern int X,Y;在主线程中运行如下程序:
void __fastcall TForm3::Button2Click(TObject *Sender)
{
pLockXY->Enter();
try{
X=1;
Y=1;
}
__finally{
pLockXY->Leave();
}
Form3->Edit1->Text=X+Y;
}
运行后报错,Access violation at address 20041918 in module 'rtl100.bpl'. Read of address 00000000'. Process Project2.exe (3944)。
请问这是哪出问题呢,先谢过大家了.
[解决办法]
你有没有这一句
pLockXY= new TCriticalSection();