Skip to content

Commit fda237a

Browse files
committed
fix(wpf): fix async warning
1 parent c6c672b commit fda237a

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

elaphureLink.Wpf/Core/Log/DataGridDataSource.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ public class DataGridDataSource
2121
// Loading data
2222
public async Task<IEnumerable<DataGridDataItem>> GetDataAsync()
2323
{
24-
_items = new ObservableCollection<DataGridDataItem>();
25-
26-
var target = NLog.LogManager.Configuration.FindTargetByName<MemoryTarget>(
27-
"logMemoryBuffer"
28-
);
24+
var target = NLog.LogManager.Configuration.FindTargetByName<MemoryTarget>("logMemoryBuffer");
2925
var logEvents = target.Logs;
3026

31-
foreach (string logLine in logEvents)
27+
return await Task.Run(() =>
3228
{
33-
string[] values = logLine.Split('|');
34-
_items.Add(
35-
new DataGridDataItem()
36-
{
37-
log_time = values[0],
38-
log_level = values[1],
39-
log_module = values[2],
40-
log_message = values[3]
41-
}
42-
);
43-
}
29+
_items = new ObservableCollection<DataGridDataItem>();
30+
foreach (string logLine in logEvents)
31+
{
32+
string[] values = logLine.Split('|');
33+
_items.Add(
34+
new DataGridDataItem()
35+
{
36+
log_time = values[0],
37+
log_level = values[1],
38+
log_module = values[2],
39+
log_message = values[3]
40+
}
41+
);
42+
}
4443

45-
return _items;
44+
return _items;
45+
});
4646
}
4747
}
4848
}

elaphureLink.Wpf/Core/WpfUpdate.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ public static async Task UpdateProgram()
1919
{
2020
Logger.Info("Start the update process");
2121

22-
2322
AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
2423
AutoUpdater.ReportErrors = true;
2524
AutoUpdater.HttpUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36";
26-
AutoUpdater.Start("https://api.github.com/repos/windowsair/elaphureLink/releases/latest");
27-
25+
await Task.Run(() => AutoUpdater.Start("https://api.github.com/repos/windowsair/elaphureLink/releases/latest"));
2826
}
2927

3028
private static void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)

0 commit comments

Comments
 (0)