Skip to content

Commit db1afa9

Browse files
authored
Code Quality: Use volatile for isMainWindowClosed (#14659)
1 parent 1c2c9ab commit db1afa9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Files.App/Data/Models/AppModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ public bool IsPasteEnabled
5858
set => SetProperty(ref isPasteEnabled, value);
5959
}
6060

61-
private bool isMainWindowClosed = false;
61+
private volatile int isMainWindowClosed = 0;
6262
public bool IsMainWindowClosed
6363
{
64-
get => isMainWindowClosed;
65-
set => SetProperty(ref isMainWindowClosed, value);
64+
get => isMainWindowClosed == 1;
65+
set
66+
{
67+
int orig = Interlocked.Exchange(ref isMainWindowClosed, value ? 1 : 0);
68+
if (isMainWindowClosed != orig)
69+
OnPropertyChanged();
70+
}
6671
}
6772

6873
private int propertiesWindowCount = 0;

0 commit comments

Comments
 (0)