Exemplo n.º 1
0
 public void NotifyPropertyChanged(params string[] changedProperties)
 {
     if (changedProperties != null)
     {
         foreach (string property in changedProperties)
         {
             InvokeHelper.Invoke(() =>
             {
                 OnPropertyChanged(property);
             });
         }
     }
 }
Exemplo n.º 2
0
 public void Append(SensorItem e)
 {
     try
     {
         InvokeHelper.Invoke(() =>
         {
             Value = e;
             History.Add(e);
             ValueChanged?.Invoke(e);
             NotifyPropertyChanged("History");
         });
     }
     catch (Exception x) {
         Debug.WriteLine(x);
     }
 }
Exemplo n.º 3
0
        public static Task <T> BeginInvokeOnMainThreadAsync <T>(Func <T> a)
        {
            var tcs = new TaskCompletionSource <T>();

            InvokeHelper.Invoke(() =>
            {
                try
                {
                    var result = a();
                    tcs.SetResult(result);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            });
            return(tcs.Task);
        }
Exemplo n.º 4
0
        public void Append(SensorItem e)
        {
            try
            {
                InvokeHelper.Invoke(() =>
                {
                    Value = e;
                    History.Add(e);
                    ValueChanged?.Invoke(e);
                    NotifyPropertyChanged("History");
                    NotifyPropertyChanged("LastSummary");
                    NotifyPropertyChanged("LastDribble");
                    NotifyPropertyChanged("DribbleHistory");
                });

                Task.Run(() => PostToApi(this, e));
            }
            catch (Exception x) {
                Debug.WriteLine(x);
            }
        }
Exemplo n.º 5
0
        async Task AddSensor(IDevice device)
        {
            if (isAddingSensor)
            {
                return;
            }

            isAddingSensor = true;
            try
            {
                SensorModel sensor = null;
                sensor = await SensorKitExtensions.BeginInvokeOnMainThreadAsync <SensorModel>(() => {
                    sensor = new SensorModel()
                    {
                        Id          = device.Id,
                        Name        = device.Name,
                        Information = Registry.Public.FirstOrDefault(s => s.Model == SensorInformation.TryParseSensorType(device.Name)),
                        IsLive      = true
                    };
                    Data.Add(sensor);
                    return(sensor);
                });

                if (sensor != null)
                {
                    InvokeHelper.Invoke(() =>
                    {
                        NotifyPropertyChanged("Data");
                    });
                }
            }catch (Exception x)
            {
                Debug.WriteLine(x);
            }
            isAddingSensor = false;
        }