First of all, code is not part of thread or an other thread, code is just a block of memory containing instructions. Think of a thread as something that goes over the code and executes each instruction. When you've got two working threads, you've got two of those things going over your code at the same time. As long as they keep working on separate data, things are all right. You'll only get into trouble when two separate threads try to change (not read) the same data at the same time. In that case, results are undefined (but there are syncrhonization objects that may be used to protect such code).
Short: as long as your second threads does nothing but read data, it's safe. Just make sure you read from simple variables / properties and you use objects that are known to be "thread safe". And please note, the VCL is not considered thread safe, those parts of it are thread safe. -- Cosmin Prund Darling, Michael wrote: > Am I right in thinking that, if you are using a separate thread to > perform a process it should not call any code in the main thread? > > I have a situation where a process is consuming a lot of time so have > moved it into its own thread, however the problem is that the process > requires a lot of the variables held on a datamodule attached to the > main form. Some are plain variables others are calculated properties but > all are static in that they are determined when the application starts > and then do not change. > > The question I have is, if I refer to the variables on the main form am > I then tying the thread back into the main thread, thus removing any > potential gain? I have only really played with threading in the past so > don't have an instinctive feel for it yet. Also would the answer be > different if just accessing say integers as opposed to calculated > properties? > > > Michael Darling > Solution Developer > ROOM Solutions Ltd > mailto:[EMAIL PROTECTED] > _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

