Data transfer from client to server
<p>I am generalising this.</p>

<p>The application has a server and a client. The server has huge data. This data has to be sent to the client and saved to a specified location. For this I am sending the data chunk by chunk.
I am expecting that the client the UI freezes.</p>

<p>To make UI responsive, I am planning to use a background thread. The idea is 
On button click, the client will ask the server to get the size of the data to read.
Once the size of the data is available, I have to ask the server to send the 
chunk. Once the data arrives and client writes to a file, then server has to send the next chunk.</p>

<p>This has to continue until last type sent.</p>

<p>I wanted to know how this can be done.</p>
