When visits are moved in the planner, I have some intensive DB / TCP Indy Socket processing which takes time, so Im thinking of moving the code to a secondary thread.
However, I still need access to the Planner.Items list etc
Im therefore thinking of creating a secondary thread with a new TPlannerItems object and assigning items from the Main thread Planner TPlannerItems to the newely created secondary thread TPlannerItems.
Is this OK to do with a TPlannerItems object???? Are you aware of any problems I might incur running TPlannerItems code in a secondary thread?
I'm not sure I fully understand what you plan to do. You will create a new & secondary instance of a TPlannerItems collection? The TPlannerItems collection has references to a TPlanner, so, it cannot be easily decoupled from the TPlanner for separately using it from a thread. Is this what you intended to do or something else?
Yes, that was my plan...... Just to try and comfirm....
I have a planner where users can move visits etc. When these visits are moved, the user releases the Left Mouse button and the the OnItemMove event and OnPlannerMouseUp events are tiggered. I have code in both these events are are lengthly ie 2-5 seonds to run.
My thought was therefore to try and create threads that would run this lenghty code in another thread ie Not the main GUI thread. This lenghtly code runs a number of processes / checks / updates etc on these moved items items eg Planner.Items.Selected item etc.
This was more question I was trying to ask..... is it possible to create another thread which would run code on these planner items? Would I need to create a new Planner object in the thread and then call something like
create new thread planner object local to thread
pass GUI planner objects to new thread
process items on thread planner object
on terminate thread / update via synchronize GUI planner items
Basically, Im trying to offload some of the processing to another thread....
I hope this makes sense????
If the processing you do after an item move done in the thread is not affecting the Planner items until after the thread has ended and the effect on items is only happening from the terminated thread in the main thread or synchronized with the main thread, then I see no issues with this approach.