8000 Fix: ODP Event manager not consistent in triggering events. by mnoman09 · Pull Request #326 · optimizely/csharp-sdk · GitHub
[go: up one dir, main page]

Skip to content

Fix: ODP Event manager not consistent in triggering events. #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
Fixed the odpEventManager flush trigger.
  • Loading branch information
NomanShoaib committed Feb 9, 2023
commit de1fc0c23d7b2b64e0c23e4136ec7af79966e566
11 changes: 7 additions & 4 deletions OptimizelySDK/Odp/OdpEventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ protected virtual void Run()
{
while (true)
{
Object item;
object item;
// If batch has events, set the timeout to remaining time for flush interval,
// otherwise wait for the new event indefinitely
if (_eventQueue.Count > 0)
if (_currentBatch.Count > 0)
{
_eventQueue.TryTake(out item, (int)(_flushingIntervalDeadline - DateTime.Now.MillisecondsSince1970()));
}
Expand All @@ -160,8 +160,11 @@ protected virtual void Run()
if (item == null)
{
// null means no new events received and flush interval is over, dispatch whatever is in the batch.
_logger.Log(LogLevel.DEBUG, $"Flushing queue.");
FlushQueue();
if (_currentBatch.Count != 0)
{
_logger.Log(LogLevel.DEBUG, $"Flushing queue.");
FlushQueue();
}
continue;
}

Expand Down
0