fixed: fixed KeyNotFoundException and improvement

This commit is contained in:
Andrzej Martyna 2026-01-03 10:29:38 +01:00
parent c75cb1acec
commit 37c733789e
2 changed files with 6 additions and 8 deletions

View file

@ -122,8 +122,8 @@ public class TabsReservationService : IDisposable
_tabsTracker.MakeSnapshot();
int expectedIndex = Math.Max(tokenHandling.LastReturnedIndex, token.Index) + 1;
var tab = _tabsTracker.TryGetTab(expectedIndex, out var foundInTrackingInfo);
trackingInfo = foundInTrackingInfo;
var (tab, info) = _tabsTracker.TryGetTab(expectedIndex);
trackingInfo = info;
if (tab != null)
{
if (tokenHandling.RequestedStill <= 1)

View file

@ -249,7 +249,7 @@ public class TabsTracker : IDisposable
List<AutomationElement> elementsToInvalidate;
lock (_syncInvalidations)
{
elementsToInvalidate = [.. _structureInvalidations];
elementsToInvalidate = _structureInvalidations.Where(_browserWindowsTracked.ContainsKey).ToList();
_structureInvalidations.Clear();
}
foreach (var element in elementsToInvalidate)
@ -307,7 +307,7 @@ public class TabsTracker : IDisposable
}
}
public AutomationElement TryGetTab(int expectedIndex, out TrackingInfo foundInTrackingInfo)
public (AutomationElement, TrackingInfo) TryGetTab(int expectedIndex)
{
lock (_sync)
{
@ -316,12 +316,10 @@ public class TabsTracker : IDisposable
var tab = trackingInfo.Cache.TryGetTab(expectedIndex);
if (tab != null)
{
foundInTrackingInfo = trackingInfo;
return tab;
return (tab, trackingInfo);
}
}
foundInTrackingInfo = null;
return null;
return (null, null);
}
}