![]() |
CreateAnonymousThread Usage? - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: CreateAnonymousThread Usage? (/thread-943.html) |
CreateAnonymousThread Usage? - cpstevenc - 02-13-2019 Greetings! Using Tokyo 10.2.3 IW 14.2.7 I started a new "Test" object to do some proof of concept stuff work work. Currently I have a REST server wrote that we use FMX iOS/Android apps talk to. Works great for past 2.5+ years. I have code that works with XSuperJSON/XSuperObject and some custom code to wrap all communications and to wrap up JSON into objects. This works great too. Sooooo... I took this existing code from my FMX app and put it into a VCL IW stand alone server program. Since the calls may take upwards of 10-15 seconds to run while it hits up the REST server.. REST server hits up a database back end, does its magic and sends back... I wanted to use a thread. I have something that "works" but not 100% sure if this is the proper way.... or can be done better. Code: .. Not sure if using the timer is the "best" way... it works... but is there a better method? After the salesSearchRequest.execute; I can't do "iwtimer1.enabled:=true;" ... as nothing happens... but if i hit F5 to refresh the page, then the timer starts working. I don't know how or if even, so i can do something like Code: salesSearchRequest.execute; // do my REST call magic Any ideas would help! ![]() As mentioned, what I have today works... but I figure better to check in to see if better/proper ways of doing this. RE: CreateAnonymousThread Usage? - kudzu - 02-14-2019 There is an async/thread/update demo in our repo. Have you taken a look at that? RE: CreateAnonymousThread Usage? - cpstevenc - 02-14-2019 (02-14-2019, 02:31 PM)kudzu Wrote: There is an async/thread/update demo in our repo. Have you taken a look at that? I saw the one in the Demo with progessbar , which is somewhat similar to what I did... but I was hoping a better way as that Demo is pretty old I think? But yah, it was IWTimer based also as wondering if better way of kicking things off.. but if this the only way/preferred way.. then so be it ... But will say it does work ok with the CreateAnonymousThread usage... RE: CreateAnonymousThread Usage? - Alexandre Machado - 02-14-2019 You can have a look at IWMonitor. There is a demo here: https://github.com/Atozed/IntraWeb/tree/master/XIV/Delphi/IWMonitor2 IWMonitor is a kind of "lightweight" timer with a few more options. The good thing about it is that it doesn't lock the user session session. IWMonitor basically watches a WebApplication property (named "Status") for changes. Whenever Status change, it will trigger an event. When the status equals a "target" value it also trigger events and you can respond to that. Please have a look and let me know if you need further help RE: CreateAnonymousThread Usage? - cpstevenc - 02-15-2019 (02-14-2019, 09:41 PM)Alexandre Machado Wrote: You can have a look at IWMonitor. There is a demo here: IWMonitor did exactly what I needed. Code: IWMonitor1.Enabled := true; Code: procedure TIWForm117.IWMonitor1AsyncTimer(Sender: TObject; EventParams: TStringList); Knowing I can do that... makes things pretty interesting ![]() Since I use tthread.CreateAnonymousThread all the time now for iOS/Android usage in FMX, I make a huge fan of it. Thanks for the heads up! |