Skip to content

Commit

Permalink
Merge pull request #116 from microsoft/bilong-watcher
Browse files Browse the repository at this point in the history
Enable watcher on background thread
  • Loading branch information
jschick04 authored May 24, 2023
2 parents 6c24883 + c964053 commit a867b48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/EventLogExpert/Store/EventLog/EventLogReducers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public static EventLogState ReduceSetContinouslyUpdate(EventLogState state, Even
Events = state.NewEventBuffer.Events.Concat(state.Events).ToList().AsReadOnly(),
NewEventBuffer = new(new List<DisplayEventModel>().AsReadOnly(), false)
};

if (state.Watcher != null && !state.Watcher.IsWatching)
{
state.Watcher.StartWatching();
}
}

return newState;
Expand Down
10 changes: 8 additions & 2 deletions src/EventLogExpert/Store/EventLog/LiveLogWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ public void StartWatching()
}
};

_watcher.Enabled = true;
// When the watcher is enabled, it reads all the events since the
// last bookmark. Do this on a background thread so we don't tie
// up the UI.
Task.Run(() =>
{
_watcher.Enabled = true;

_debugLogger.Trace("LiveLogWatcher started watching.");
_debugLogger.Trace("LiveLogWatcher started watching.");
});
}

public void StopWatching()
Expand Down

0 comments on commit a867b48

Please sign in to comment.