private void EventBasedNetListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { //Not the used connector = end if (!IsConnected) { return; } DatagramPayload payload; using (MemoryStream memoryStream = new MemoryStream()) { memoryStream.Write(reader.Data, 0, reader.AvailableBytes); memoryStream.Seek(0, SeekOrigin.Begin); payload = (DatagramPayload)_formatter.Deserialize(memoryStream); } SimulatorDataSet simulatorDataSet = _datagramPayloadUnPacker.UnpackDatagramPayload(payload); if (payload.PayloadKind == DatagramPayloadKind.SessionStart || _firstPackage) { _firstPackage = false; SessionStarted?.Invoke(this, new DataEventArgs(simulatorDataSet)); } else { DataLoaded?.Invoke(this, new DataEventArgs(simulatorDataSet)); } }
/// <summary> /// Raises the on load event. /// </summary> protected void OnDataLoaded() { if (DataLoaded != null) { DataLoaded.Invoke(); } }
/// <summary> /// Lädt die Daten von http://schletz.org/fetchData und schreibt sie in die Datenbank. /// </summary> /// <returns></returns> private async Task LoadAsync() { try { // GetAsync kann einen CancellationToken haben, GetStringAsync nicht. HttpResponseMessage response = await client.GetAsync("http://schletz.org/fetchData", cancellation.Token); // HTTP 200? if (!response.IsSuccessStatusCode) { return; } string data = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <IEnumerable <Value> >(data); using (StationDb db = new StationDb()) { HashSet <int> existingStations = new HashSet <int>(db.Stations.Select(s => s.ID)); db.Values.AddRange(result.Where(v => existingStations.Contains(v.STATION))); try { await db.SaveChangesAsync(cancellation.Token); // Laden ist fertig, daher wird das Event aufgerufen. DataLoaded?.Invoke(this, new EventArgs()); } catch { } } } // GetAsync wirft eine Exception, wenn der Task abgebrochen wurde. catch (TaskCanceledException) { } catch { } }
public void LoadData() { if (NamesLoaded && EducationLoaded && OrphanDataLoaded && HealthLoaded && AddressLoaded) { DataLoaded?.Invoke(this, new EventArgs()); } else { GetAutoCompleteStrings(); } }
public async void LoadAccounts() { var accoutnsCount = await _apiClient.Accounts_GetAccountsCountAsync(); var ReturnedAccoutns = await _apiClient.Accounts_GetAllAsync(accoutnsCount, 0); _SourceAccounts = ReturnedAccoutns; Accounts = new ObservableCollection <AccountModel>(_mapperService.MapToAccountModel(_SourceAccounts)); DataLoaded?.Invoke(this, new EventArgs()); }
private void RaiseDataLoadedEvent(SimulatorDataSet data) { try { DataEventArgs args = new DataEventArgs(data); _oldDataSet = data; DataLoaded?.Invoke(this, args); } catch (Exception) { LogSimulatorDataSet(_oldDataSet); throw; } }