11using System ;
22using System . Collections . Generic ;
3+ using System . ComponentModel ;
4+ using System . Runtime . CompilerServices ;
35
46using IPConfig . Models ;
57
@@ -9,6 +11,21 @@ namespace IPConfig.Helpers;
911
1012public static class LiteDbHelper
1113{
14+ private static bool _isDbBusy ;
15+
16+ public static bool IsDbBusy
17+ {
18+ get => _isDbBusy ;
19+ private set
20+ {
21+ if ( _isDbBusy != value )
22+ {
23+ _isDbBusy = value ;
24+ OnStaticPropertyChanged ( ) ;
25+ }
26+ }
27+ }
28+
1229 public static void Handle ( Action < ILiteCollection < EditableIPConfigModel > > action )
1330 {
1431 Handle ( col => {
@@ -20,14 +37,14 @@ public static void Handle(Action<ILiteCollection<EditableIPConfigModel>> action)
2037
2138 public static T Handle < T > ( Func < ILiteCollection < EditableIPConfigModel > , T > func )
2239 {
23- App . IsDbSyncing = true ;
40+ IsDbBusy = true ;
2441
2542 using var db = new LiteDatabase ( "Filename=ipconfig.db; Connection=Shared;" ) ;
2643 var col = db . GetCollection < EditableIPConfigModel > ( "ipconfigs" ) ;
2744
2845 var result = func ( col ) ;
2946
30- App . IsDbSyncing = false ;
47+ IsDbBusy = false ;
3148
3249 return result ;
3350 }
@@ -58,4 +75,15 @@ public static T Query<T>(Func<IEnumerable<EditableIPConfigModel>, T> func)
5875 return result ;
5976 } ) ;
6077 }
78+
79+ #region Static Properties Change Notification
80+
81+ public static event EventHandler < PropertyChangedEventArgs > StaticPropertyChanged = delegate { } ;
82+
83+ private static void OnStaticPropertyChanged ( [ CallerMemberName ] string ? staticPropertyName = null )
84+ {
85+ StaticPropertyChanged ( null , new PropertyChangedEventArgs ( staticPropertyName ) ) ;
86+ }
87+
88+ #endregion Static Properties Change Notification
6189}
0 commit comments