private void ExecuteWithSyncIO() { Stopwatch sw = Stopwatch.StartNew(); for (Int32 n = 0; n < c_iterations; n++) { Cargo cargo = CargoFactory.CreateNew("Glyfada" + n, "Perachora" + n); App.Database.Save(typeof(Cargo), cargo); } SetStatus("Sync/IO completed.", StatusState.Ready); }
public void StoreAndLoad() { Cargo cargo = CargoFactory.CreateNew("Glyfada", "Perachora"); m_repository.Store(cargo); Cargo saved = m_repository.Find(cargo.TrackingId); Debug.Assert(cargo.RouteSpecification.Equals(saved.RouteSpecification)); Debug.Assert(cargo.Delivery.Equals(saved.Delivery)); Debug.Assert(cargo.Equals(saved)); }
private void ExecuteWithEventBased() { IList <Cargo> cargos = new List <Cargo>(); for (Int32 n = 0; n < c_iterations; n++) { Cargo cargo = CargoFactory.CreateNew("Glyfada" + n, "Perachora" + n); cargos.Add(cargo); } var bw = App.Database.SaveAsync <Cargo>(cargos); bw.RunWorkerCompleted += (sender, e) => { SetStatus("Event-based completed.", StatusState.Ready); }; bw.RunWorkerAsync(); }
private void ExecuteWithIAsyncResult() { SetStatus("Working..", StatusState.Busy); for (Int32 n = 0; n < c_iterations; n++) { Cargo cargo = CargoFactory.CreateNew("Glyfada" + n, "Perachora" + n); App.Database.BeginSave <Cargo>(cargo, (ar) => { App.Database.EndSave(ar); if (Interlocked.Increment(ref m_numDone) == c_iterations) { Execute.OnUIThread(() => { SetStatus("IAsyncResult APM completed.", StatusState.Ready); }); } }, null); } }
private IEnumerator <Int32> ExecuteWithAsyncEnumerator(AsyncEnumerator ae) { for (Int32 n = 0; n < c_iterations; n++) { Cargo cargo = CargoFactory.CreateNew("Glyfada" + n, "Perachora" + n); App.Database.BeginSave <Cargo>(cargo, ae.End(), null); } // NOTE: AsyncEnumerator captures the calling thread's SynchronizationContext. // Set the Wintellect.Threading.AsyncProgModel.SynchronizationContext type to // null so that the callback continues on a ThreadPool thread. ae.SyncContext = null; yield return(c_iterations); for (Int32 n = 0; n < c_iterations; n++) { App.Database.EndSave(ae.DequeueAsyncResult()); } // AsyncEnumerator captures the synchronization context. SetStatus("AsyncEnumerator completed.", StatusState.Ready); }
private static Cargo FactoryMethod() { return(CargoFactory.CreateNew("Glyfada", "Perachora")); }