33// Distributed under the MIT software license, see the accompanying
44// file LICENCE or http://www.opensource.org/licenses/mit-license.php.
55
6+ using Avalonia . Threading ;
67using FinderOuter . Models ;
78using System ;
89using System . Numerics ;
9- using System . Text ;
1010
1111namespace FinderOuter . Services
1212{
@@ -21,16 +21,19 @@ public ServiceBase(Report rep)
2121 }
2222
2323
24-
2524 private readonly Report report ;
26- private readonly StringBuilder queue = new StringBuilder ( ) ;
2725
2826
2927 protected void InitReport ( )
3028 {
3129 report . CurrentState = State . Working ;
3230 report . Message = string . Empty ;
33- queue . Clear ( ) ;
31+ }
32+
33+ protected bool FinishReport ( bool success )
34+ {
35+ report . CurrentState = success ? State . FinishedSuccess : State . FinishedFail ;
36+ return success ;
3437 }
3538
3639 protected void AddMessage ( string msg )
@@ -54,15 +57,8 @@ protected bool Pass(string msg)
5457
5558 protected void AddQueue ( string msg )
5659 {
57- queue . AppendLine ( msg ) ;
58- }
59-
60- protected bool CopyQueueToMessage ( bool hasPassed )
61- {
62- report . CurrentState = hasPassed ? State . FinishedSuccess : State . FinishedFail ;
63- AddMessage ( queue . ToString ( ) ) ;
64-
65- return hasPassed ;
60+ Dispatcher . UIThread . InvokeAsync ( ( ) =>
61+ report . Message += string . IsNullOrEmpty ( report . Message ) ? msg : $ "{ Environment . NewLine } { msg } ") ;
6662 }
6763
6864 protected string GetKeyPerSec ( BigInteger total , double totalSecond )
@@ -76,6 +72,5 @@ protected string GetKeyPerSec(BigInteger total, double totalSecond)
7672 return $ "k/s= { total / new BigInteger ( totalSecond ) : n0} ";
7773 }
7874 }
79-
8075 }
8176}
0 commit comments