bonjour,
la méthode LockList() descend de la classe TThreadList
cette méthode empêche q'un autre thread utilise cette liste et elle te retourne un ptr sur sur une TList
TList* __fastcall LockList(void);
mais si comme je le suppose la threadList est vide (valeur NULL) l'appel a LockList va provoquer forcément un Access Violation
pour le tester modifie ton code de la manière suivante
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
try
{
TList *ListeThread = IdIRCServer1->Threads->LockList();
for( int i=0; i<ListeThread->Count; i++ )
{
try
{
TIdPeerThread *Thread = (TIdPeerThread*)ListeThread->Items[i];
Thread->Connection->WriteLn( "PING MaTHieU" );
}
catch( ... )
{
TIdPeerThread *Thread = (TIdPeerThread*)ListeThread->Items[i];
Thread->Stop();
}
}
IdIRCServer1->Threads->UnlockList();
}
catch(EAccessViolation &E)
{
MessageBox(Handle,E.Message, "Exception Occurs", MB_OK + MB_ICONSTOP);
} |
Cordialement
Partager