title: How upload files to azure in background with Delphi and OmniThread?
body: <p>I have tried to upload +100 files to azure with Delphi. However, the calls block the main thread, so I want to do this with a async call or with a background thread.</p>
  
  <p>This is what I do now (like <a href="http://www.thedelphigeek.com/2011/10/omnithreadlibrary-in-practice-1web.html">explained here</a>):</p>
  
  <pre><code>procedure TCloudManager.UploadTask(const input: TOmniValue;
    var output: TOmniValue);
  var
    FileTask:TFileTask;
  begin
    FileTask := input.AsRecord&lt;TFileTask&gt;;
  
    Upload(FileTask.BaseFolder, FileTask.LocalFile, FileTask.CloudFile);
  end;
  
  function TCloudManager.MassiveUpload(const BaseFolder: String;
    Files: TDictionary&lt;String, String&gt;): TStringList;
  var
    pipeline: IOmniPipeline;
    FileInfo : TPair&lt;String,String&gt;;
    FileTask:TFileTask;
  begin
    // set up pipeline
    pipeline := Parallel.Pipeline
      .Stage(UploadTask)
      .NumTasks(Environment.Process.Affinity.Count * 2)
      .Run;
    // insert URLs to be retrieved
    for FileInfo in Files do
    begin
      FileTask.LocalFile := FileInfo.Key;
      FileTask.CloudFile := FileInfo.Value;
      FileTask.BaseFolder := BaseFolder;
  
      pipeline.Input.Add(TOmniValue.FromRecord(FileTask));
    end;//for
  
    pipeline.Input.CompleteAdding;
  
    // wait for pipeline to complete
    pipeline.WaitFor(INFINITE);
  end;
  </code></pre>
  
  <p>However this block too (why? I don't understand).</p>