5

I am calling a servermethod from within a thread using Omnithreadlibrary, the data is returned succesfully, but I have troubles using the data returned, everything i've tried goes with AccessViolation or even crash of the application, tryed also to set the dataset in the a DataSetProvider linked to a ClientDataSet, but here also it doesn't work, at last I set the server method to return an OleVariant and set it directly to the Data Property of the ClientDataSet but I had an errors also.

My purpose is to have the request done in a thread and data returned to a function in the main thread to pupulate the grid.

any suggestions?

g13013
  • 51
  • 2
  • I suggest making it work in a non-theaded setup and work on it from there. Also, use 2 clientdatasets, populate a decoupled CDS in your thread, when you're done, link it to the grid. Then you can populate the other CDS (now decoupled) in a thread again. A classic beat-and-switch aka double buffering scheme. – Johan Nov 18 '11 at 16:12
  • Some more info about CDS and threads: http://stackoverflow.com/questions/669319/delphi-is-tclientdataset-thread-safe – Heinrich Ulbricht Nov 18 '11 at 16:32
  • I've finally managed to do it with the Data param of the ClientDataSet, my mistake was when setting the active to true in the ClientDataSet after puting the Data, so now after retrievind the result I work with the ClientDataSet always non active. But your suggestion also is a good Idea, I will try it later. the difference is in my method, I create only 1 ClientDataSet on the form, call the method withing the thread by sending a message and put the Data to the ClientDataSet, at the end I activate the grid. – g13013 Nov 18 '11 at 19:59

0 Answers0