Skip to content

Commit 7ee3e46

Browse files
committed
screenshot lock
1 parent 6ceb8ae commit 7ee3e46

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Models/WatchLocation.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ internal sealed class WatchLocation
99
public Guid SaveGameId { get; set; }
1010
public string Location { get; set; }
1111
public string GameDirectory { get; set; }
12-
public bool IsTakingScreenshot { get; set; }
1312
}

Services/ScreenshotService.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,15 @@ private void OnChanged(object sender, FileSystemEventArgs args)
195195

196196
if (_watchers.TryGetValue(directory, out WatchLocation watchLocation))
197197
{
198-
if (!watchLocation.IsTakingScreenshot)
198+
try
199199
{
200-
watchLocation.IsTakingScreenshot = true;
201-
202-
try
200+
if (Monitor.TryEnter(watchLocation, TimeSpan.FromSeconds(10)))
203201
{
204202
string saveDirectory = Path.Combine(_config.BackupsDirectory, watchLocation.SaveGameId.ToString());
205203
TakeScreenshot(saveDirectory, watchLocation.GameDirectory);
206204
}
207-
finally
208-
{
209-
watchLocation.IsTakingScreenshot = false;
210-
}
211205
}
206+
catch { }
212207
}
213208
}
214209
}

0 commit comments

Comments
 (0)