private async void Request_OnStateChanged(object Sender, SensorDataReadoutState NewState) { try { if (NewState == SensorDataReadoutState.Done) { string[] Fields; lock (this.fieldsSorted) { Fields = new string[this.fieldsSorted.Count]; this.fieldsSorted.Keys.CopyTo(Fields, 0); } this.availableFieldNames = Fields; await Database.Update(this); DispatcherOperation Op = MainWindow.currentInstance.Dispatcher.BeginInvoke(new ThreadStart(() => { SortedDictionary <string, bool> Selected = null; bool AllSelected = this.fieldNames == null; if (!AllSelected) { Selected = new SortedDictionary <string, bool>(StringComparer.CurrentCultureIgnoreCase); foreach (ListBoxItem Item in this.fieldsListBox.Items) { if (Item.IsSelected) { Selected[(string)Item.Tag] = true; } } } this.fieldsListBox.Items.Clear(); foreach (string FieldName in this.availableFieldNames) { this.fieldsListBox.Items.Add(new ListBoxItem() { Content = FieldName, IsSelected = AllSelected || Selected.ContainsKey(FieldName), Tag = FieldName }); } })); } } catch (Exception ex) { Log.Critical(ex); } }
internal void Fail(string Reason) { lock (this.synchObject) { if (this.errors == null) { this.errors = new List <ThingError>(); } this.errors.Add(new ThingError(string.Empty, string.Empty, string.Empty, DateTime.Now, Reason)); } this.State = SensorDataReadoutState.Failure; }
internal async Task SetState(SensorDataReadoutState NewState) { if (this.state != NewState) { this.state = NewState; SensorDataReadoutStateChangedEventHandler h = this.OnStateChanged; if (!(h is null)) { try { await h(this, NewState); } catch (Exception ex) { Log.Critical(ex); } } } }
private void OnStateChanged(object P) { SensorDataReadoutState NewState = (SensorDataReadoutState)P; switch (NewState) { case SensorDataReadoutState.Requested: this.StateLabel.Content = "Requested"; break; case SensorDataReadoutState.Accepted: this.StateLabel.Content = "Accepted"; break; case SensorDataReadoutState.Started: this.StateLabel.Content = "Started"; break; case SensorDataReadoutState.Receiving: this.StateLabel.Content = "Receiving"; break; case SensorDataReadoutState.Done: this.StateLabel.Content = "Done"; this.Done(); break; case SensorDataReadoutState.Cancelled: this.StateLabel.Content = "Cancelled"; break; case SensorDataReadoutState.Failure: this.StateLabel.Content = "Failure"; this.Done(); break; default: this.StateLabel.Content = NewState.ToString(); break; } }
internal void Accept(bool Queued) { this.queued = Queued; this.State = SensorDataReadoutState.Accepted; }
internal void Fail(string Reason) { this.LogErrors(new ThingError[] { new ThingError(string.Empty, string.Empty, string.Empty, DateTime.Now, Reason) }); this.State = SensorDataReadoutState.Failure; }
private Task Request_OnStateChanged(object _, SensorDataReadoutState NewState) { MainWindow.UpdateGui(this.OnStateChanged, NewState); return(Task.CompletedTask); }
private void Request_OnStateChanged(object Sender, SensorDataReadoutState NewState) { this.Dispatcher.BeginInvoke(new ParameterizedThreadStart(this.OnStateChanged), NewState); }
private Task Subscription_OnStateChanged(object _, SensorDataReadoutState NewState) { Log.Informational("Sensor subscription state changed.", NewState.ToString()); return Task.CompletedTask; }
private Task Subscription_OnStateChanged(object obj, SensorDataReadoutState NewState) { Console.WriteLine("Sensor subscription state changed." + NewState.ToString()); return(Task.CompletedTask); }
private void Request_OnStateChanged(object Sender, SensorDataReadoutState NewState) { MainWindow.UpdateGui(this.OnStateChanged, NewState); }