Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What about using the Parallel library on a List of queued apps to install?</p> <p>As svick says in the comments above, the process of trying to download then install is very synchronous, so you would not need tasks for that but just some sequential code.</p> <p>But for downloading all apps and install in parallel at the same time, you may want to fill a List of apps with your data and download + install methods, then just use the Parallel library to exectue all in parallel. Here is an example, I guessed a lot of things from your post but should give you an idea of what I'm talking about.</p> <p>If you wish to also have the whole thing in a separate task and do other things while all apps download in parallel, you can enclose the Parallel code in a task and execute it somewhere else in your code, continue woorking on other things then finally wait for the task to finish.</p> <p>This could be a class for each App you want to download:</p> <pre><code>/// &lt;summary&gt; /// Class for each of your apps to be downloaded and installed. You can also /// derive this in other types of apps that require a different download or install /// approach. /// &lt;/summary&gt; class AppToDownload { /// &lt;summary&gt; /// The addresses to download this app /// &lt;/summary&gt; public List&lt;string&gt; DownloadAddresses { get; set; } /// &lt;summary&gt; /// Flag that tells if this task was successfully installed. Set to false /// as default. /// &lt;/summary&gt; public bool Installed { get; set; } /// &lt;summary&gt; /// Constructor /// &lt;/summary&gt; /// &lt;param name="downloadAddresses"&gt;Addresses to download this app from, they /// should be in order of preference&lt;/param&gt; public AppToDownload(List&lt;string&gt; downloadAddresses) { this.DownloadAddresses = downloadAddresses; this.Installed = false; } /// &lt;summary&gt; /// Public method to be called to Install this app. It will download, and if /// successful, will install /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public bool InstallApp() { this.Installed = (this.TryDownload() &amp;&amp; this.TryInstall()); return this.Installed; } /// &lt;summary&gt; /// Internal method to download this App. You can override this in a derived /// class if you need to. /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; protected virtual bool TryDownload() { bool res = false; // (...) Your code to download, return true if successful return res; } /// &lt;summary&gt; /// Internal method to install this App. You can override this in a derived /// class if you need to. /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; protected virtual bool TryInstall() { bool res = false; // (...) Your code to install, return true if successful return res; } } </code></pre> <p>Then here is the code that will download and install all apps in parallel. You can also use an instance of the class ParallelOptions to personalize how the Parallel loop works.</p> <pre><code>List&lt;AppToDownload&gt; queuedApps = new List&lt;AppToDownload&gt;(); // (...) Fill the list of apps // Try Install all Apps in parallel Parallel.ForEach(queuedApps, (app) =&gt; app.InstallApp()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload