Hi Dennis I think I've fixed the problem. I created private variables in the thread and used Synchronize to copy the data from the UI to these variables before doing the time consuming process. It seems to be behaving itself now.
Thanks all, Ross Levis. ----- Original Message ----- From: "Dennis Chuah" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, September 25, 2003 8:18 AM Subject: Re: [DUG]: random thread crashes > > Using synchronize does not negate the benefits of using a thread. It all > depends on how you are using synchronize. For example, you might have a > lengthy process and you want that to run in the background. When you create > the thread - in suspend mode, you can pass it parameters (eg. create > properties on the TThread subclass). You then tell the thread to resume. > On your UI, you might have a cancel button that when clicked, sets a boolean > variable. Periodically, the thread may check the value of this variable and > terminates if required. You can protect access to this variable using a > simple critical section lock. However, the thread also needs to tell the UI > when it has complete. This can be done using synchronize - the sync. method > runs in the main thread and can safely access the VCL. > > How much data does the thread need to read from your UI controls? > > ----- Original Message ----- > From: "Ross Levis" <[EMAIL PROTECTED]> > To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> > Sent: Wednesday, September 24, 2003 3:40 PM > Subject: Re: [DUG]: random thread crashes > > > > Hi Dennis > > > > Using synchronize will negate the effect of using a thread in the first > > place. I'm not using any methods but I am reading properties. Should I > > copy the value of all properties into say global variables before calling > > the thread? > > > > Regards, > > Ross Levis. > > > > ----- Original Message ----- > > From: "Dennis Chuah" <[EMAIL PROTECTED]> > > To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> > > Sent: Wednesday, September 24, 2003 2:02 PM > > Subject: Re: [DUG]: random thread crashes > > > > > > > > > > The VCL is not thread safe and parts of it are not re-entrant. You > might > > > need to use synchronize to sync to your main thread before you call any > > VCL > > > methods. > > > > -------------------------------------------------------------------------- > - > > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > > Website: http://www.delphi.org.nz > > To UnSub, send email to: [EMAIL PROTECTED] > > with body of "unsubscribe delphi" > > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > > -------------------------------------------------------------------------- - > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
