How to implement a progress bar with TIdTCPClient? - delphi

I am using indy 10 and i was wondering how can i implement a progress bar for transfering a file.I tried with onWork events but they are not triggred. Another thing that i find anoying is that the application freezes until the stream is downloaded.
What am i doing wrong ?

Add an IdAntiFreeze component to your form and use it's properties and events to get notified of the progress of the network operations.

You can put the download code into another thread using TThread so that your app doesn't freeze while downloading, and have a procedure that you send to TThread.Synchronize to update the progress bar. Also, for OnWork to be called, you have to call OnWorkBegin first, see http://www.borlandtalk.com/image-vp569607.html

Related

Fmx update control without applicatio.processmessages

What is the best way to update FMX control without using Apllication.Processmessages method, וn main form.
Apllication.Processmessages call can cause to unwanted asynchrony user events to come in before operation completed.
We have old delphi XE5 in ms windows 10, i tried repaint and invalidate but it not help.
Have the OnClick handler disable the button, start a background thread/task to do the actual work, show the "please wait" message, and then exit the OnClick handler. Do not block the main thread at all. Let it run so it can process UI work normally as needed.
When your background work is finished, have the thread/task notify the main thread, which can then dismiss the "please wait" message and re-enable the button.
DO NOT do the actual work in the OnClick handler itself, and DO NOT call Application.ProcessMessages() at all.

On iPhone, How to display Animation while loading from server?

I want to implement animation like This link while application interact with server.
If someone has example to implement this kind of animation then please provide me link.
Start animation
Server request in background thread
End animation in completion block of server request in the main thread
If you want that specific one I think you are going to have to make it yourself, but if you don't here are some open source alternatives.
DGActivityIndicatorView
MONActivityIndicatorView
YRActivityIndicator
interaction designer at Creativedash here =]
For something like that you'd make a png sequence, and set the animationImages property of a UIImageView. iOS is great at animating png sequences.
When your load starts, do yourLoadingImage.startAnimating() and when it's over (in the completion for your request), call yourLoadingImage.stopAnimating().
There's a property called animationDuration, and you need to set that as well, just to indicate how long the animation loop is - this doesn't indicate how long the animation will play for. It loops until you tell it to stop.
yourLoadingImage.animationDuration = 1 //set the loop duration to 1s
We actually did a short blog post on this process, and it can be the same for really any custom loader. http://news.ui8.net/create-a-custom-animated-loading-indicator-with-swift/

How To Update UIProgressView after UITextField DidEndOnExit

I have a UITextField, which checks a password and then my app loads data from a remote server. While this is happening I would like a progress view to display the progress of the download. My issue is that the UITextField seems to lock up the display until it returns and therefore I cannot update the progress view on the main thread. I also would like an answer without GCD or any other kind of threading as I am using core data and that would probably overcomplicate the app. Is there a way to have the UITextField not lock up the view so that I can update my progressView on the main thread?
If your app is loading data from a remote server, then you will have to use multi-threading(GCD, etc). Otherwise it just locks up the main thread till the download is finished which makes your app unresponsive.
To keep it simple, use GCD to fetch data(raw NSData) and give it to the main thread. Do all your processing on the main thread(core data, etc) as usual.
EDIT: One more thing, it is not the textfield locking up your UI, it is the download. So I don't think you can do anything other than multi-threading to help you here.

TAniIndicator not animating while performing an action.

In my application, I have actions/buttons that are linked to queries that load new forms and populate tables with data. I would like to have an animated spinner animate while the queries load.
My current code has by default the TaniIndicator.visible/enabled properties set to false and then when the button is pressed to load the new form, the procedure begins by enabling both of those TaniIndicator properties, however, in my application, the spinner never shows and only is faint to see once the queries are finished and the new form is ready to appear. help ?
Using Delphi xe4, developing an iOS application.
It is because you perform your query on the main thread, and UI updates is blocked while the query is executing. You should start indicator, detach a new background thread or queue, launch task on that thread. Once it is done, switch back to main thread and hide or stop the indicator.
I just coded:
application.processMessages
as the article suggested by #LU RD guides to...
Was no need to create another Thread.

iOS - QLPreviewController delay

I have an app that generates a PDF and displays it at the same time. As expected, there is about a 2-second delay between pressing the "Generate PDF" button and the QLPreviewController presenting the document. Not only that, it appears as though the document fades in momentarily, freezes, and then completes the fade-in.
I understand that the reason for the delay is because it is generating the PDF first, but the design of the application doesn't allow for any other mechanism. I was hoping to put a brief "LOADING..." animation before the QLPreviewController view appears, but everything I've tried so far still presents a 2-second delay.
Can anyone provide guidance on what I might be able to do here?
There are lots of options. I'd suggest that whatever you do, it be asynchronous. This will allow for the UI to not 'freeze' and you can put a loading screen up even if it is for 2 seconds.
There are many ways to implement this. Some involve actual background threads and others don't.
You can use, delegates, NSNotifications, blocks, NSOperations, and/or Grand Central Dispatch.
Here's a tutorial on how to use Grand Central Dispatch
Here's a tutorial on blocks

Resources