Mr. E 6 Posted October 26, 2018 OK, I was trying to ask how to rewrite a Application that I create using thread to be more responsive, then I found this video: OmniThread Library - Primoz Gabrijelcic Thursday, September 3, 2015 What I need starts at Async/Await demo (t=300) So I'll leave the link, I will see it, read and practice to see if I can re write my application. Regards Share this post Link to post
KodeZwerg 54 Posted October 27, 2018 Hello there, did you read http://www.omnithreadlibrary.com/documentation/ ? You will also find Examples there. 2 Share this post Link to post
KodeZwerg 54 Posted October 27, 2018 Dear Primož Gabrijelčič, on your site those links need to be fixed: ADUG 2011 - Getting Full Speed with Delphi You put %2520 inside link names = no link work. %20 would fix links. 1 Share this post Link to post
Primož Gabrijelčič 223 Posted October 27, 2018 @KodeZwerg Fixed, thank you! 1 Share this post Link to post
KodeZwerg 54 Posted October 27, 2018 (edited) 10 minutes ago, Primož Gabrijelčič said: @KodeZwerg Fixed, thank you! Confirm. Thankyou for that great resource! Edited October 27, 2018 by KodeZwerg Share this post Link to post
Mr. E 6 Posted October 27, 2018 Strange, I recompile two projects (Berlin), now, running on the target computer, the previous versions works but the new version shows this message: (of course I just jump on the video and don't read the docs :shame, following @KodeZwerg advice now) Quote Exception: 10/27/2018 10:22:42.389 ---------------------------------------------------------------------------- Microsoft MSXML is not installed Share this post Link to post
Mr. E 6 Posted October 27, 2018 I don't find any information about OTL related with this msxml issue. Looks like is not related, maybe is something wrong with my project configuration. I'll check the project/IDE, recompile the original code and see if this error occurs. (fingers crossed) Share this post Link to post
Primož Gabrijelčič 223 Posted October 28, 2018 Run it in the debugger and check where this exception pops up. Share this post Link to post
Guest Posted October 28, 2018 (edited) MSXML needs (which is internally called by the UI main thread) CoInitialize https://stackoverflow.com/questions/43858447/delphi-load-xml-file-within-a-thread Edited October 28, 2018 by Guest Share this post Link to post
Mr. E 6 Posted October 29, 2018 @Primož Gabrijelčič, yes the exception pops up. I remotely connect to my office to check it, and now I see that I'm using and OTL old version, updating now. The exception occurs, following @Schokohase advice and was right. Looks like access that web services needs your advice to works. So I need to add "ActiveX" on the uses clause: uses ... , ActiveX , OTLparallel; // add the procedure TForm1.doConnectionToService begin try CoInitialize(nil); //... wsServicio := Servicio.GetServicioSoap(cbUseWSDL.Checked); //... except on E : Exception do begin //... end; end; CoUninitialize; end; // on my clic event procedure TForm1.bbConectarClick(Sender: TObject); begin bbConectar.Caption:= 'Comprobando Acceso...'; bbConectar.Enabled:= False; // The old annoying unresponsive way: // doConectar; // bbConectar.Caption:= '&1) Comprobar Acceso'; // bbConectar.Enabled:= True; // The new code without unresponsive GUI! Thank you Primoz G. Async(doConectar) .Await( procedure begin bbConectar.Caption:= '&1) Comprobar Acceso'; bbConectar.Enabled:= True; end); end; Maybe there need to be a new entry in the OTL FAQ because I don't find any reference (I wasn't searching thoroughly). Thank you for the help! Regards Share this post Link to post
Guest Posted October 29, 2018 But this is not an OTL issue. The SOAP client uses MSXML and MSXML needs CoInitialize. Delphi already do call it for you in GUI applications for the UI thread. But in a console application you have to do that by yourself, as you have to call that on any other thread. You will have the same problems when working with TThread or TPL or OTL or ... anything else which will use a thread different from the main thread. Share this post Link to post
Mr. E 6 Posted October 29, 2018 5 minutes ago, Schokohase said: But this is not an OTL issue. ... You will have the same problems when working with TThread or TPL or OTL or ... anything else which will use a thread different from the main thread. Hence the nature of this post, for the new users of this great library. But it's official, I need to read more documentation of OTL, learn and be aware of changes that need care, Delphi really do a great job lifting the weight for us. I manage to fix one application; and I got a some more that can beneficed using OTL. Some other app trows me an unexpected AV error, it just consume another web services, open some xml file, inspect that some elements are present then upload to that service. At the end, closing the app got this: Delphi and threads: “System Error. Code: 1400. Invalid window handle (need to read tomorrow and fix it) Regards! Share this post Link to post
Primož Gabrijelčič 223 Posted October 29, 2018 (edited) 16 hours ago, Mr. E said: Maybe there need to be a new entry in the OTL FAQ because I don't find any reference (I wasn't searching thoroughly). This is mentioned in the book: http://www.omnithreadlibrary.com/book/chap10.html#howto-com P.S. Make sure that you don't call any VCL code from your background threads! Edited October 29, 2018 by Primož Gabrijelčič 1 Share this post Link to post
Mr. E 6 Posted October 29, 2018 (edited) 9 hours ago, Primož Gabrijelčič said: This is mentioned in the book: http://www.omnithreadlibrary.com/book/chap10.html#howto-com P.S. Make sure that you don't call any VCL code from you background threads! Thank you @Primož Gabrijelčič, now I know what to read & learn "7.12 OmniThreadLibrary and COM/OLE" Edit: Seeing your recommendation about VCL; if I need to update a TListView with the output of each call of the web service, then I'll need to divide my code so I can update that VCL controls. 💭 Edit #2: @Primož Gabrijelčič Is correct this approach? Asyn(do_something_with_the_webservices) .Await( procedure begin // Can I update ListView controls here? // ... more code inside end); Edit #3 . (To myself) First read the docs, then ask later! [ self.slap ] .. Edited October 29, 2018 by Mr. E .. Share this post Link to post