Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In Asp.Net I use a lot of <strong>static</strong> methods for jobs to be done. If its simply a job where I need <strong>no response</strong> or status, I do something simple like below. As you can see I can choose to call either ResizeImages or ResizeImagesAsync depending if I want to wait for it to finish or not</p> <p><em>Code explanation: I use <a href="http://imageresizing.net/" rel="nofollow">http://imageresizing.net/</a> to resize/crop images and the method SaveBlobPng is to store the images to Azure (cloud) but since that is irrelevant for this demo I didn't include that code. Its a good example of time consuming tasks though</em></p> <pre><code>private delegate void ResizeImagesDelegate(string tempuri, Dictionary&lt;string, string&gt; versions); private static void ResizeImagesAsync(string tempuri, Dictionary&lt;string, string&gt; versions) { ResizeImagesDelegate worker = new ResizeImagesDelegate(ResizeImages); worker.BeginInvoke(tempuri, versions, deletetemp, null, null); } private static void ResizeImages(string tempuri, Dictionary&lt;string, string&gt; versions) { //the job, whatever it might be foreach (var item in versions) { var image = ImageBuilder.Current.Build(tempuri, new ResizeSettings(item.Value)); SaveBlobPng(image, item.Key); image.Dispose(); } } </code></pre> <p>Or going for threading so you dont have to bother with Delegates</p> <pre><code>private static void ResizeImagesAsync(string tempuri, Dictionary&lt;string, string&gt; versions) { Thread t = new Thread (() =&gt; ResizeImages(tempuri, versions, null, null)); t.Start(); } </code></pre>
 

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