Jump to content
JackT

Problem with TStringList on thread

Recommended Posts

I am creating a string list on a thread inside a function like this

 

class AQNI : public TThread

{

//Some definitions

}

 

AQNI * mythread;

 

bool AQNI::ReadXMLData

{

     TStringList * ATB = new TStringList();  //Access violation occurs here the 2nd time the thread is created

{

//DO SOME STUFF

}

__finally

{

delete ATB;

}

return true;

}

 

The first time the thread is created everything runs fine. After I have finished with threaded object I destroy the thread and wait for a command and to start a data collection loop at which point I Free and delete mythread.

However when I recreate my thread and call the ReadXMLData function when I try to create a fresh string list the whole thing falls over with an access violation. I am surprised the code is broken because it was previously working. 

 

The exception is ocuring in BorlndMM ( Borland Memory Manager )

 

:69d29df9 BORLNDMM.@Borlndmm@SysGetMem$qqri + 0x3d

 

Edited by JackT

Share this post


Link to post

There is not enough information to diagnose your problem. How are you creating and destroying the thread? Are you really destroying the thread TWICE before starting a new thread? What is your thread code doing besides creating the TStringList? We need to see a more complete code example. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×