UsnWatcher: Add Run() and RunShared() sync methods to match Rust API
Browse files
FastSeekWpf/Core/UsnWatcher.cs
CHANGED
|
@@ -102,6 +102,33 @@ public class UsnWatcher : IDisposable
|
|
| 102 |
return count;
|
| 103 |
}
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
public async Task RunAsync(CancellationToken ct)
|
| 106 |
{
|
| 107 |
_running = true;
|
|
|
|
| 102 |
return count;
|
| 103 |
}
|
| 104 |
|
| 105 |
+
/// <summary>Synchronous run loop — matches Rust UsnWatcher::run()</summary>
|
| 106 |
+
public void Run()
|
| 107 |
+
{
|
| 108 |
+
byte[] buffer = new byte[65536];
|
| 109 |
+
while (!_disposed)
|
| 110 |
+
{
|
| 111 |
+
Thread.Sleep(500);
|
| 112 |
+
Poll();
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/// <summary>Synchronous run with shared checkpoint updates — matches Rust UsnWatcher::run_shared()</summary>
|
| 117 |
+
public void RunShared(List<JournalCheckpoint> sharedCheckpoints)
|
| 118 |
+
{
|
| 119 |
+
byte[] buffer = new byte[65536];
|
| 120 |
+
while (!_disposed)
|
| 121 |
+
{
|
| 122 |
+
Thread.Sleep(500);
|
| 123 |
+
Poll();
|
| 124 |
+
lock (sharedCheckpoints)
|
| 125 |
+
{
|
| 126 |
+
sharedCheckpoints.RemoveAll(c => c.DriveLetter == _drive.Letter);
|
| 127 |
+
sharedCheckpoints.Add(Checkpoint());
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
public async Task RunAsync(CancellationToken ct)
|
| 133 |
{
|
| 134 |
_running = true;
|