@@ -54,6 +54,8 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal
5454 // (unconditionally, unlike HostScanned), so it's flushed to the bound property on the same
5555 // timer instead of updating it directly from the background thread on every event.
5656 private int _latestHostsScanned ;
57+ private int _latestHostsUp ;
58+ private int _latestHostsDown ;
5759
5860 /// <summary>
5961 /// Gets or sets the host or IP range to scan.
@@ -209,6 +211,38 @@ public int HostsScanned
209211 }
210212 }
211213
214+ /// <summary>
215+ /// Gets or sets the number of hosts found to be reachable so far.
216+ /// </summary>
217+ public int HostsUp
218+ {
219+ get ;
220+ set
221+ {
222+ if ( value == field )
223+ return ;
224+
225+ field = value ;
226+ OnPropertyChanged ( ) ;
227+ }
228+ }
229+
230+ /// <summary>
231+ /// Gets or sets the number of hosts found to be unreachable so far.
232+ /// </summary>
233+ public int HostsDown
234+ {
235+ get ;
236+ set
237+ {
238+ if ( value == field )
239+ return ;
240+
241+ field = value ;
242+ OnPropertyChanged ( ) ;
243+ }
244+ }
245+
212246 /// <summary>
213247 /// Gets or sets a value indicating whether the scan is being prepared.
214248 /// </summary>
@@ -456,6 +490,17 @@ private async Task Start()
456490
457491 Results . Clear ( ) ;
458492
493+ // Reset before hostname resolution too (not just after), so a cancellation during
494+ // resolution can't flush the previous scan's stale totals - HostsToScan = 0 also hides
495+ // the up/down summary until the new scan's host count is known.
496+ HostsToScan = 0 ;
497+ HostsScanned = 0 ;
498+ HostsUp = 0 ;
499+ HostsDown = 0 ;
500+ Volatile . Write ( ref _latestHostsScanned , 0 ) ;
501+ Volatile . Write ( ref _latestHostsUp , 0 ) ;
502+ Volatile . Write ( ref _latestHostsDown , 0 ) ;
503+
459504 DragablzTabItem . SetTabHeader ( _tabId , Host ) ;
460505
461506 _cancellationTokenSource ? . Dispose ( ) ;
@@ -484,8 +529,6 @@ private async Task Start()
484529 }
485530
486531 HostsToScan = hosts . hosts . Count ;
487- HostsScanned = 0 ;
488- Volatile . Write ( ref _latestHostsScanned , 0 ) ;
489532
490533 PreparingScan = false ;
491534
@@ -768,20 +811,29 @@ private void FlushResultsBuffer()
768811 /// pick up on the next timer tick, instead of updating the bound property directly from a
769812 /// background thread on every single host.
770813 /// </summary>
771- /// <param name="sender">The source of the event.</param>
814+ /// <param name="sender">The <see cref="IPScanner"/> instance raising the event.</param>
772815 /// <param name="e">The <see cref="ProgressChangedArgs"/> instance containing the event data.</param>
773816 private void ProgressChanged ( object sender , ProgressChangedArgs e )
774817 {
775818 Volatile . Write ( ref _latestHostsScanned , e . Value ) ;
819+
820+ if ( sender is IPScanner ipScanner )
821+ {
822+ Volatile . Write ( ref _latestHostsUp , ipScanner . HostsUp ) ;
823+ Volatile . Write ( ref _latestHostsDown , ipScanner . HostsDown ) ;
824+ }
776825 }
777826
778827 /// <summary>
779- /// Pushes the latest buffered progress value into <see cref="HostsScanned"/>. Always called
780- /// on the UI thread - same calling contexts as <see cref="FlushResultsBuffer"/>.
828+ /// Pushes the latest buffered progress value into <see cref="HostsScanned"/>,
829+ /// <see cref="HostsUp"/> and <see cref="HostsDown"/>. Always called on the UI thread - same
830+ /// calling contexts as <see cref="FlushResultsBuffer"/>.
781831 /// </summary>
782832 private void FlushProgress ( )
783833 {
784834 HostsScanned = Volatile . Read ( ref _latestHostsScanned ) ;
835+ HostsUp = Volatile . Read ( ref _latestHostsUp ) ;
836+ HostsDown = Volatile . Read ( ref _latestHostsDown ) ;
785837 }
786838
787839 /// <summary>
0 commit comments