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Ä 227 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Ä 227 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Ä 227 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