Skip to content

Commit 99d4b3f

Browse files
committed
AsyncObservableColleciton removed, DispatcherPriotity added
1 parent ad103e1 commit 99d4b3f

9 files changed

Lines changed: 32 additions & 84 deletions

File tree

‎Source/NETworkManager/Collections/AsyncObservableCollection.cs‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

‎Source/NETworkManager/NETworkManager.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,6 @@
905905
</Compile>
906906
<Compile Include="ApplicationViewManager.cs" />
907907
<Compile Include="ApplicationViewInfo.cs" />
908-
<Compile Include="Collections\AsyncObservableCollection.cs" />
909908
<Compile Include="Models\Network\ProgressChangedArgs.cs" />
910909
<Compile Include="Models\Network\TracerouteHopInfo.cs" />
911910
<Compile Include="Models\Network\TracerouteHopReceivedArgs.cs" />

‎Source/NETworkManager/ViewModels/DNSLookupViewModel.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
using System.Collections.Generic;
55
using System.Windows;
66
using System.Windows.Input;
7-
using NETworkManager.Collections;
87
using System.Windows.Threading;
98
using System.Diagnostics;
109
using Heijden.DNS;
1110
using System.Linq;
1211
using System.ComponentModel;
1312
using System.Windows.Data;
1413
using NETworkManager.Utilities;
14+
using System.Collections.ObjectModel;
1515

1616
namespace NETworkManager.ViewModels
1717
{
@@ -76,8 +76,8 @@ public bool IsLookupRunning
7676
}
7777
}
7878

79-
private AsyncObservableCollection<DNSLookupRecordInfo> _lookupResult = new AsyncObservableCollection<DNSLookupRecordInfo>();
80-
public AsyncObservableCollection<DNSLookupRecordInfo> LookupResult
79+
private ObservableCollection<DNSLookupRecordInfo> _lookupResult = new ObservableCollection<DNSLookupRecordInfo>();
80+
public ObservableCollection<DNSLookupRecordInfo> LookupResult
8181
{
8282
get { return _lookupResult; }
8383
set
@@ -371,7 +371,7 @@ private void DNSLookup_RecordReceived(object sender, DNSLookupRecordArgs e)
371371
{
372372
DNSLookupRecordInfo DNSLookupRecordInfo = DNSLookupRecordInfo.Parse(e);
373373

374-
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate ()
374+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
375375
{
376376
LookupResult.Add(DNSLookupRecordInfo);
377377
}));

‎Source/NETworkManager/ViewModels/IPScannerViewModel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private void IpScanner_HostFound(object sender, IPScannerHostFoundArgs e)
513513
{
514514
IPScannerHostInfo ipScannerHostInfo = IPScannerHostInfo.Parse(e);
515515

516-
Application.Current.Dispatcher.BeginInvoke(new Action(delegate ()
516+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
517517
{
518518
IPScanResult.Add(ipScannerHostInfo);
519519
}));

‎Source/NETworkManager/ViewModels/PingViewModel.cs‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
using System.Threading;
99
using System.Windows;
1010
using System.Windows.Input;
11-
using NETworkManager.Collections;
1211
using System.ComponentModel;
1312
using System.Diagnostics;
1413
using System.Windows.Threading;
1514
using System.Windows.Data;
1615
using Dragablz;
1716
using NETworkManager.Controls;
1817
using NETworkManager.Utilities;
18+
using System.Collections.ObjectModel;
1919

2020
namespace NETworkManager.ViewModels
2121
{
@@ -30,7 +30,7 @@ public class PingViewModel : ViewModelBase
3030
Stopwatch stopwatch = new Stopwatch();
3131

3232
private bool _isLoading = true;
33-
33+
3434
private string _host;
3535
public string Host
3636
{
@@ -79,8 +79,8 @@ public bool CancelPing
7979
}
8080
}
8181

82-
private AsyncObservableCollection<PingInfo> _pingResult = new AsyncObservableCollection<PingInfo>();
83-
public AsyncObservableCollection<PingInfo> PingResult
82+
private ObservableCollection<PingInfo> _pingResult = new ObservableCollection<PingInfo>();
83+
public ObservableCollection<PingInfo> PingResult
8484
{
8585
get { return _pingResult; }
8686
set
@@ -92,6 +92,13 @@ public AsyncObservableCollection<PingInfo> PingResult
9292
}
9393
}
9494

95+
private ICollectionView _pingResultView;
96+
public ICollectionView PingResultView
97+
{
98+
get { return _pingResultView; }
99+
}
100+
101+
95102
private int _pingsTransmitted;
96103
public int PingsTransmitted
97104
{
@@ -270,8 +277,12 @@ public PingViewModel(int tabId, string host)
270277
_tabId = tabId;
271278
Host = host;
272279

280+
// Set collection view
273281
_hostHistoryView = CollectionViewSource.GetDefaultView(SettingsManager.Current.Ping_HostHistory);
274282

283+
// Result view
284+
_pingResultView = CollectionViewSource.GetDefaultView(PingResult);
285+
275286
LoadSettings();
276287

277288
_isLoading = false;
@@ -455,7 +466,7 @@ private void AddHostToHistory(string host)
455466
}
456467

457468
public void OnClose()
458-
{
469+
{
459470
// Stop the ping
460471
if (IsPingRunning)
461472
PingAction();
@@ -468,7 +479,10 @@ private void Ping_PingReceived(object sender, PingReceivedArgs e)
468479
PingInfo pingInfo = PingInfo.Parse(e);
469480

470481
// Add the result to the collection
471-
PingResult.Add(pingInfo);
482+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
483+
{
484+
PingResult.Add(pingInfo);
485+
}));
472486

473487
// Calculate statistics
474488
PingsTransmitted++;
@@ -489,10 +503,10 @@ private void Ping_PingReceived(object sender, PingReceivedArgs e)
489503

490504
if (MaximumTime < pingInfo.Time)
491505
MaximumTime = pingInfo.Time;
492-
}
493506

494-
// I don't know if this can slow my application if the collection is to large
495-
AverageTime = (int)PingResult.Average(s => s.Time);
507+
// I don't know if this can slow my application if the collection is to large
508+
AverageTime = (int)PingResult.Select(s => s.Time).Average();
509+
}
496510
}
497511
else
498512
{

‎Source/NETworkManager/ViewModels/PortScannerViewModel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ private void PortScanner_PortScanned(object sender, PortScannedArgs e)
622622
{
623623
PortInfo portInfo = PortInfo.Parse(e);
624624

625-
Application.Current.Dispatcher.BeginInvoke(new Action(delegate ()
625+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
626626
{
627627
PortScanResult.Add(portInfo);
628628
}));

‎Source/NETworkManager/ViewModels/SNMPViewModel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ private void Snmp_Received(object sender, SNMPReceivedArgs e)
604604
{
605605
SNMPReceivedInfo snmpReceivedInfo = SNMPReceivedInfo.Parse(e);
606606

607-
Application.Current.Dispatcher.BeginInvoke(new Action(delegate ()
607+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
608608
{
609609
QueryResult.Add(snmpReceivedInfo);
610610
}));

‎Source/NETworkManager/ViewModels/TracerouteViewModel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ private void Traceroute_HopReceived(object sender, TracerouteHopReceivedArgs e)
480480
{
481481
TracerouteHopInfo tracerouteInfo = TracerouteHopInfo.Parse(e);
482482

483-
Application.Current.Dispatcher.BeginInvoke(new Action(delegate ()
483+
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate ()
484484
{
485485
TraceResult.Add(tracerouteInfo);
486486
}));

‎Source/NETworkManager/Views/PingView.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<TextBlock Grid.Row="2" Foreground="{DynamicResource AccentColorBrush}" Text="{Binding StatusMessage}" Visibility="{Binding DisplayStatusMessage, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{DynamicResource DefaultTextBlock}" Margin="0,10,0,0" />
120120
</Grid>
121121
<TextBlock Grid.Row="2" Text="{DynamicResource String_Header_Status}" Style="{StaticResource HeaderTextBlock}" />
122-
<Control:ScrollingDataGrid Grid.Row="3" ItemsSource="{Binding PingResult}" Margin="0,0,0,20">
122+
<Control:ScrollingDataGrid Grid.Row="3" ItemsSource="{Binding PingResultView}" Margin="0,0,0,20">
123123
<Control:ScrollingDataGrid.Resources>
124124
<Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource ScrollingDataGridScrollBar}" />
125125
</Control:ScrollingDataGrid.Resources>

0 commit comments

Comments
 (0)