Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class OrderViewModel : Notifier
- {
- DispatcherTimer dispatcherTimer = new DispatcherTimer();
- private SoftproofTransporterClientApi api = new SoftproofTransporterClientApi();
- private ObservableCollection<Order> _orders = new ObservableCollection<Order>();
- public ObservableCollection<Order> Orders
- {
- get { return _orders; }
- set { PropertySetter(ref _orders, "Orders", value); }
- }
- public OrderViewModel()
- {
- dispatcherTimer.Tick += new EventHandler(UpdateOrders);
- dispatcherTimer.Interval = new TimeSpan(0, 0, 2);
- dispatcherTimer.Start();
- }
- private void UpdateOrders(object sender, EventArgs e)
- {
- GetOrders();
- }
- private void GetOrders()
- {
- api.GetOrders((orderResult) =>
- Deployment.Current.Dispatcher.BeginInvoke( ()=>
- {
- DateTime dt = DateTime.Now;
- string time = String.Format("{0:d/M/yyyy HH:mm:ss}", dt);
- try
- {
- Orders = orderResult.Orders;
- Debug.WriteLine("Updated Orders at " + time);
- }
- catch { Debug.WriteLine("Could not get Orders at " + time); }
- })
- );
- }
- }
Add Comment
Please, Sign In to add comment