/// <summary> /// Запустить бесконечный цикл прослушивания /// </summary> /// <returns></returns> private async Task RunListen() { try { while (isRunListen) { string messageReceive = await myPipeClientServer.Listen(); if (messageReceive == COMMAND_STOP) { isRunListen = false; return; } DataUpdated?.Invoke(this, new DataUpdatedEventArgs <string>(new NetworkVariableData <string>(messageReceive))); } } catch (Exception ex) { // ошибка возникает при закрытии слушающего ожидающего подключения, // которая перехватывается здесь Debug.WriteLine("ERROR: {0}", ex.ToString()); WriteCompleted?.Invoke(this, new WriteCompletedEventArgs(ex, false, this)); } }
// HACK: This should not be here and solved differently, because it messes up the internal state public virtual void SetDimensionAtIndex(int dataIndex, int dimensionIndex) { _dataDimensionsIndices[dimensionIndex] = dataIndex; var e = new DataPresenterEventArgs(); DataUpdated?.Invoke(this, e); }
public void Reset() { stack.Clear(); _current = 1; _count = 0; DataUpdated?.Invoke(); }
public async void Refresh() { await refreshLock.WaitAsync(); if (!IsValid || DateTime.UtcNow - lastRefresh > TimeSpan.FromMinutes(15)) { try { await GetCurrentConditions(); await GetForecast(); lastRefresh = DateTime.UtcNow; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } } refreshLock.Release(); if (DataUpdated != null) { DataUpdated.Invoke(this, EventArgs.Empty); } }
public void OnNext(AFDataPipeEvent value) { if (value.Action != AFDataPipeAction.Delete) { DataUpdated?.Invoke(this, new EventArgs <AFValue>(value.Value)); } }
internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); TimeSpan = new TimeSpan((Int64)sensorData.timestamp); X = sensorData.values[0]; Y = sensorData.values[1]; Z = sensorData.values[2]; BiasX = sensorData.values[3]; BiasY = sensorData.values[4]; BiasZ = sensorData.values[5]; DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated magnetometer sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for uncalibrated magnetometer"); } }
internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); Timestamp = sensorData.timestamp; if (sensorData.values[0] == 0) { Rotation = AutoRotationState.Degree_0; } else { Rotation = (AutoRotationState)sensorData.values[0]; } Accuracy = sensorData.accuracy; DataUpdated?.Invoke(this, new AutoRotationSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for auto-rotation sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for auto-rotation"); } }
internal override void EventListenStart() { _callback = (IntPtr sensorHandle, IntPtr eventPtr, uint events_count, IntPtr data) => { updateBatchEvents(eventPtr, events_count); Interop.SensorEventStruct sensorData = latestEvent(); TimeSpan = new TimeSpan((Int64)sensorData.timestamp); StepCount = (uint)sensorData.values[0]; WalkStepCount = (uint)sensorData.values[1]; RunStepCount = (uint)sensorData.values[2]; MovingDistance = sensorData.values[3]; CalorieBurned = sensorData.values[4]; LastSpeed = sensorData.values[5]; LastSteppingFrequency = sensorData.values[6]; LastStepStatus = (PedometerState)sensorData.values[7]; DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); }; int error = Interop.SensorListener.SetEventsCallback(ListenerHandle, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for pedometer sensor"); throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for pedometer"); } }
/// <summary> /// Clear the highlight flags for all indices. /// </summary> public void ClearHighlights() { for (int i = 0; i < _highlightedItems.Length; i++) { _highlightedItems[i] = false; } DataUpdated?.Invoke(this, new DataPresenterEventArgs()); }
public GameDoubler(int finish) { this._finish = finish; _current = 1; _count = 0; DataUpdated?.Invoke(); //minCount=? }
private void OnDataUpdated(FirebaseEvent <BattleData> evt) { currentBattle = evt.Object; if (currentBattle.LastPlayingPlayerId != ApplicationData.PlayerId) { DataUpdated?.Invoke(evt.Object); } }
/// <summary> /// Called whenever the data of the DataProvider has changed. /// </summary> /// <param name="sender">The DataProvider which data has changed.</param> /// <param name="e">The event arguments.</param> protected virtual void Provider_DataUpdated(object sender, EventArgs e) { if (_highlightedItems.Length != _dataProvider.Data.NumOfItems) { _highlightedItems = new bool[_dataProvider.Data.NumOfItems]; } //TODO: Check dataSet dimensions, items count, etc. DataUpdated?.Invoke(this, new DataPresenterEventArgs(_selectedMinItem, _selectedMaxItem)); }
public void ForceRenew() { if (UpdateInfo()) { DeleteImages(); DecodeData(); DataUpdated?.Invoke(this); } }
public async Task ResetCardDataAsync() { CachedCards = null; ActiveDataSource = DataSources[0]; CardDataInfoUrl = string.Format(DefaultCardInfoUrl, ActiveDataSource); Settings.ActiveCardDataVersion = null; Settings.HighestNotifiedCardDataVersion = Settings.ActiveCardDataVersion; DataUpdated?.Invoke(this, await GetCachedCardsAsync()); }
// periodically raise gui update event private void updateGui() { if ((DateTime.Now - this.lastGuiUpdate).TotalSeconds >= guiUpdatePeriod) { lastGuiUpdate = DateTime.Now; GuiUpdateEvent?.Invoke(); } DataUpdated?.Invoke(); }
public async Task dothis() { EventStreamResponse response = await client.OnAsync("DavesTrain/passengers", (sender, args, context) => { if (DataUpdated != null) { DataUpdated.Invoke(this, EventArgs.Empty); } }); }
/// <summary> /// Toggles the highlight flag for the specified index. /// </summary> /// <param name="index">The index for which the highlight should be toggled.</param> public virtual void ToogleItemHighlight(int index) { _highlightedItems[index] = !_highlightedItems[index]; HighlightChanged?.Invoke(this, index); if (index >= _selectedMinItem || index < _selectedMaxItem) { DataUpdated?.Invoke(this, new DataPresenterEventArgs()); } }
public void Undo() { if (stack.Count > 0) { _current = stack.Pop(); _count--; } DataUpdated?.Invoke(); }
public async void Delete(Entry EntryToDelete) { await Task.Run(() => { Entrys.Remove(EntryToDelete); Data.Save(Entrys, Sellers, Assortment); }); DataUpdated?.Invoke(null, null); }
protected virtual void HandleEvent(IncomingMessage message) { switch (message.e) { case "shutdown": Console.WriteLine($"Server is going to close this connection: {message.d}"); break; case "props": string eventType = "", entityType = ""; JObject entity = null; object entityObject = null; foreach (var prop in (message.d as JContainer).Values <JProperty>()) { switch (prop.Name) { case "eventType": eventType = prop.Value.ToString(); break; case "entityType": entityType = prop.Value.ToString(); break; case "entity": entity = prop.Value as JObject; break; default: Log.Write($"Unrecognized event property: {prop}"); break; } } NotificationTaskQueue.Enqueue(() => { if (entity != null) { Cache.Update(eventType, entityType, entity); try { var typeName = entityType[0].ToString().ToUpper() + entityType.Substring(1); typeName = $"Tradovate.Services.Model.{typeName}"; var type = Type.GetType(typeName, true); entityObject = JsonConvert.DeserializeObject(entity.ToString(), type); } catch (Exception ex) { Console.Error.WriteLine($"Cannot deserialize event's entity: {entityType}, {entity}, {ex}"); } } DataUpdated?.Invoke(this, new DataUpdate(eventType, entityType, entityObject)); }); break; } }
public void SetList(List <ClientFolderEndpoint> folders) { _items.Clear(); _items.AddRange(folders.Select(x => new FolderListDataItem { DisplayName = x.DisplayName, Id = x.Id, })); DataUpdated?.Invoke(); }
public void SetServerListFromConfig(IReadOnlyCollection <ServerConfigItem> configServers) { itemsList.Clear(); itemsList.AddRange(configServers.Select(x => new ServerListDataItem { Address = x.Url, Id = x.Id, })); DataUpdated?.Invoke(); }
public void SetServerListFromConfig(IEnumerable <FolderConfigItem> configServers) { _items.Clear(); _items.AddRange(configServers.Select(x => new FolderListDataItem { DisplayName = x.DisplayName, LocalPath = x.LocalPath, Id = x.Id, })); DataUpdated?.Invoke(); }
/// <summary> /// Updates the specified data log in this table. /// </summary> /// <param name="dataLog">The <see cref="ActivityDataLog" /> to update.</param> internal void Update(ActivityDataLog dataLog) { ValidateType(dataLog); if (!Records.ContainsKey(dataLog.RecordId)) { throw new DataLoggerMockException($"The {TableName} table received an Update command for a record that does not exist."); } Records[dataLog.RecordId].Update(dataLog); DataUpdated?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Adds a new data log record to this table. /// </summary> /// <param name="dataLog">The <see cref="ActivityDataLog" /> to add.</param> internal void Add(ActivityDataLog dataLog) { ValidateType(dataLog); if (Records.ContainsKey(dataLog.RecordId)) { throw new DataLoggerMockException(string.Format("The {0} table received a record with a duplicate key.", TableName)); } Records.Add(dataLog.RecordId, new DataLoggerMockRecord(dataLog)); DataUpdated?.Invoke(this, EventArgs.Empty); }
private void DataUpdatedEvent() { while (Stopwatch.GetTimestamp() - _lastUpdateTime < 100 * TickResolMs) { if (AbortEdiabasJob()) { break; } Thread.Sleep(100); } _lastUpdateTime = Stopwatch.GetTimestamp(); DataUpdated?.Invoke(this, EventArgs.Empty); }
internal void ReportLoadCompleted(StreamedFileFailureMode?failure = null) { // Note: this is expected to be invoke more than once! _failure ??= failure; if (!_isCompleted) { _isCompleted = true; DataUpdated?.Invoke(this, default); } }
public void Build(IProgress progress) { if (!_slices.Any()) { return; } initCommonProperties(_slices.First()); XSize = _slices.First().width; YSize = _slices.First().height; ZSize = _slices.Count; Pixels = new ushort[_slices.Count, XSize, YSize]; progress.Min(1); progress.Max(ZSize); progress.Reset(); _minDens = ushort.MaxValue; _maxDens = ushort.MinValue; for (int z = 0; z < ZSize; z++) { for (int x = 0; x < XSize; x++) { for (int y = 0; y < YSize; y++) { Pixels[z, x, y] = _slices[z].pixels.ElementAt(x * XSize + y); if (Pixels[z, x, y] > _maxDens) { _maxDens = Pixels[z, x, y]; } if (Pixels[z, x, y] < _minDens) { _minDens = Pixels[z, x, y]; } } } progress.Tick(); } _slices.Clear(); Task.Factory.StartNew(GC.Collect); DataUpdated?.Invoke(); }
private void Poll() { var report = _device.ReadReport(); if (report == null) { Logger.Debug("JoyCon Canceled " + this); return; } _device.Write(new byte[] { 0x01, 0x00 }); var deviceData = _device.Read(); if (deviceData.Status != HidDeviceData.ReadStatus.Success) { return; } var joyConState = JoyConInputUtils.ReadInput(deviceData.Data, Type); if (joyConState != null && !joyConState.Equals(CurrentState)) { CurrentState = joyConState; Task.Run(() => DataUpdated?.Invoke(this, new JoyConDataUpdateEventArgs(this, joyConState))); if (IsPaired) { //Splitting state changed? if (_currentInSplittingState != (joyConState.SideLeftButton || joyConState.SideRightButton)) { _currentInSplittingState = joyConState.SideLeftButton || joyConState.SideRightButton; //Invoke splitting event async Task.Run(() => Splitting?.Invoke(this, new JoyConSplittingEventArgs( this, _currentInSplittingState ? SplittingType.ReadyToSplit : SplittingType.CancelSplitting ))); } } else { //Pairing state changed? if (_currentInPairingState != joyConState.RearBackButton) { _currentInPairingState = joyConState.RearBackButton; //Invoke ready to pair or paring cancel event async Task.Run(() => Pairing?.Invoke(this, new JoyConPairingEventArgs( this, _currentInPairingState ? PairingType.ReadyToPair : PairingType.CancelPairing ))); } } } }
public async void FilterByProdcut(Product product) { if (_filterProduct.Equals(product)) { return; } else { _filterProduct = product; } await ItemList.FilterAsync(Filter); UpdateData(); DataUpdated?.Invoke(null, new EventArgs()); }