public static ICancellable BuildAsync(Action<Awful.Core.Models.ActionResult, SAThreadPage> result, SAThread thread, bool refresh = false, int pageNumber = 0, int userID = 0) { BackgroundWorker worker = new BackgroundWorker(); Factory.AddDoWorkEvent(worker, thread, refresh, pageNumber, userID); Factory.AddRunWorkCompletedEvent(worker, result); CancellableTask task = new CancellableTask(worker); worker.RunWorkerAsync(); return task; }
public static ICancellable BuildAsync(Action<Awful.Core.Models.ActionResult, SAThreadPage> result, SAThreadPage page) { TaskCompletedDelegate completed = (obj, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => { if (args.Cancelled) { result(Awful.Core.Models.ActionResult.Cancelled, page); } else { Awful.Core.Models.ActionResult ar = (Awful.Core.Models.ActionResult)args.Result; result(ar, page); } }); }; DoWorkDelegate work = Factory.BuildAsync_DoWork; CancellableTask task = new CancellableTask(work, completed); task.Worker.RunWorkerAsync(page); return task; }