private void LoadMessages() { AsyncWorker.Execute( () => { var result = new EntityCollection <MessageEntity>(); try { using (var adapter = new DataAccessAdapter()) { adapter.FetchEntityCollection(result, null); } } catch { } return(result); }, (response) => { if (response == null) { return; } ProcessResponseLoadMessages(response); }, this, ModelStatus.Saving); }
private void LoadData() { AsyncWorker.Execute(() => { var result = new List <StandardViewModel>(); for (var counter = 1; counter <= 100; counter++) { var customer = new StandardViewModel { Text1 = GetRandomFirstName() + " " + GetRandomLastName(), Text2 = GetRandomCompany() }; result.Add(customer); } Thread.Sleep(2000); // Simulating a slow process return(result); }, result => { Customers.Clear(); foreach (var subscriber in result) { subscriber.LoadSharedImage1FromBrushResource("CODE.Framework-Icon-Contact2"); Customers.Add(subscriber); } }, this); }
public AsyncTest() { InitializeComponent(); var taskId = Guid.NewGuid(); AsyncWorker.Execute(() => DateTime.Now.ToString(), time => display.Text += time + "\r\n", new TimeSpan(0, 0, 0, 5), processId: taskId); AsyncWorker.Execute(() => "Hello! " + Environment.TickCount.ToString(), time => display.Text += time + "\r\n", new TimeSpan(0, 0, 0, 2)); AsyncWorker.PauseContinuousProcess(taskId); AsyncWorker.ResumeContinuousProcess(taskId); AsyncWorker.StopContinuousProcess(taskId); }