OnThreadRecord - passing record out

clivew

Member²
I need to run a query in a thread and want to display each record as it is processed.

The problem is that the TOracleQuery is running in a DataModule and the results will be displayed on a form (or other Display object) so I am wondering what is the best way to pass the information to the display vehicle in a way that is both loosely coupled and thread safe.
So two issues:
1. How to pass the data row around there does not appear to be a DataRow class (like Java).

2. If I roll my own mini-class to hold the row of data (easy enough for me, if I have to) how do I make sure that the data reaches the display object within the Thread Synchronization that OnThreadRecord initiates.
 
If you are using the TOracleQuery.Threaded property, you need to enable the TOracleQuery.ThreadSynchronized option to ensure that thread events occur synchronized with the main thread of your application. This way you can safely pass data to the visual controls on your forms.

There is indeed no datarow class, so you will either need to create your own class or access the TOracleQuery instance directly.
 
Marco,

Thanks for the response; but it did not answer my real question. I will try to ask it more clearly. The loosely coupled issue.

1. Have a DataRow object in a DataRow class unit.
2. In onThreadRecord
begin
Ask DataRow unit for a DataRow object and fill it
end;

3. On my form (or other display or storage object)
Begin
Ask DataRow unit for a specific DataRow object
Use it to display/store the information.
end;

I just don't know where or how the thread, the main application and the synchronization you create interact.

Can you help with this?

Thanks,
Clive

 
There are various methods to make the Form and the OnThreadRecord interact:

1. Create the OnThreadRecord event in the Forum module and assign it to the TOracleQuery.OnThreadRecord event.
2. Create a new event in the data module, assign it to a form event handler, and call it from the TOracleQuery.OnThreadRecord event. This allows you to easily pass and process the DataRow instance.
3. Post a message to the main application from the TOracleQuery.OnThreadRecord event.

As stated in my previous reply, the TOracleQuery.ThreadSynchronized property controls how the TOracleQuery.OnThreadRecord event is synchronized with the main thread of your application.
 
Back
Top