Note that there are some explanatory texts on larger screens.

plurals
  1. POMake Wpf more Smooth
    text
    copied!<p>I load a lage data fra a text File and display it in a Datatgrid, the problem is that the windows is slow and not smootth, how can i implemented the code below better?</p> <p><strong>the button Code:</strong></p> <pre><code> private async void MILoadLogFile_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box OpenFileDialog oFD = new OpenFileDialog(); // Did they click on the OK button? if (oFD.ShowDialog() == true) { await myLogSession.LoadfromFileAsync(oFD.FileName); } } </code></pre> <p><strong>the locad method:(sorry for long Code)</strong></p> <pre><code> public async Task LoadfromFileAsync(String fileName) { compassLogCollection.Clear(); StreamReader streamReader = new StreamReader(fileName); if (fileName.Contains("Compass")) { String temp = ""; String line; DateTime dateTime = new DateTime(); LoggingLvl loggingLvl = new LoggingLvl(); LoggingLvl.ELoggingLvl eLoggingLvl = new LoggingLvl.ELoggingLvl(); char[] delimiters = new[] {' '}; string threadId = ""; string loggingMessage; string dateAndTimestamp = ""; int ff = 0; try { using (streamReader) { while ((line = await streamReader.ReadLineAsync()) != null) { //while ((line = streamReader.ReadLine()) != null) { string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); foreach (string t in parts) { switch (ff) { case 0: dateAndTimestamp = t; break; case 1: dateAndTimestamp += " " + t.Replace(",", "."); dateTime = DateTime.Parse(dateAndTimestamp); dateAndTimestamp = ""; break; case 2: eLoggingLvl = loggingLvl.ParseLoggingLvl(t); break; case 3: threadId = t; break; default: temp += t; break; } ff++; } loggingMessage = temp; temp = ""; ff = 0; loggingLvl = new LoggingLvl(eLoggingLvl); CompassLogData cLD = new CompassLogData(dateTime, loggingLvl, threadId, loggingMessage); compassLogCollection.Add(cLD); } Console.Out.WriteLine("DOOOOOOOOOOOOONE"); } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload