protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/plain"; Guid job = Guid.NewGuid(); BatchResizeSettings s = new BatchResizeSettings(MapPath("~/Results/" + job.ToString() + ".zip"), job, new List <BatchResizeItem>()); string[] sourceImages = System.IO.Directory.GetFiles(Path.GetFullPath(MapPath("~/").TrimEnd('\\') + "\\..\\Images"), "*"); foreach (string img in sourceImages) { s.files.Add(new BatchResizeItem(img, null, "?width=100")); } s.ItemEvent += new ItemCallback(s_ItemEvent); s.JobEvent += new JobCallback(s_JobEvent); //Executes on a thread pool thread BatchResizeManager.BeginBatchResize(s); ///Executes synchronously. Use BatchResizeManager.BeginBatchResize(s) for async execution. //new BatchResizeWorker(s).Work(); }
void bwResizeBatch_DoWork(object sender, DoWorkEventArgs e) { if (DoWorkEvent != null) { DoWorkEvent(this, new DoWorkEventArgs(e.Argument)); } count = 0; try { Dictionary <string, object> UserInputs = e.Argument as Dictionary <string, object>; if (UserInputs != null) { ResizeSettings rs = new ResizeSettings((string)UserInputs["querystring"]); batchItems = (List <BatchInfo>)UserInputs["batchItems"]; total = batchItems.Count; Guid job = Guid.NewGuid(); var s = new BatchResizeSettings(Properties.Settings.Default.saveZipPath, job, new List <BatchResizeItem>()); foreach (var item in batchItems) { s.files.Add(new BatchResizeItem(item.FullPath, null, rs.ToStringEncoded())); } s.ItemEvent += s_ItemEvent; s.JobEvent += s_JobEvent; new BatchResizeWorker(s).Work(); } } catch (Exception ex) { // handle the exception. } }