question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MainLoop.RunTimers() method throws System.ArgumentException after few hours.

See original GitHub issue

Can someone explain me why I’m getting this error after around 8 hours of running? Terminal.Gui version 1.4

AmiAI - System.ArgumentException: An item with the same key has already been added. Key: 637865266986268040 (Parameter "key") at System.Collections.Generic.SortedList"2.Add(TKey key, TValue value) at Terminal.Gui.MainLoop.RunTimers() at Terminal.Gui.MainLoop.MainIteration() at Terminal.Gui.Application.RunLoop(RunState state, Boolean wait) at Terminal.Gui.Application.Run(Toplevel view, Func"2 errorHandler) at Terminal.Gui.Application.Run(Func"2 errorHandler) at Pai.Ama.Run() at Pai.Program.Main(String[] args)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:23

github_iconTop GitHub Comments

2reactions
kacperpikaczcommented, May 6, 2022

@tznind your code modification fixed the issue on MacOS. No more problems during 23 hours.

2reactions
tznindcommented, May 4, 2022

But at first sight it mainly do the same thing as original but using a method.

RunTimers has an if/else statement in it. The ‘if’ condition uses AddTimer but the ‘else’ just directly added to the dictionary. My PR adds the collision dodging to that else statement not just a new method.

foreach (var t in copy) {
		var k = t.Key;
		var timeout = t.Value;
		if (k < now) {
			if (timeout.Callback (this))
				AddTimeout (timeout.Span, timeout); // has the collision dodging code
		} else {
			lock (timeoutsLockToken) {
				timeouts.Add (k, timeout); // does not have the collision dodging code
			}
		}
	}

Old code (prior to PR)

Read more comments on GitHub >

github_iconTop Results From Across the Web

MainLoop.RunTimers() method throws System. ...
After changing the code and starting timers via Application.Mainloop.Invoke(), the program didn't throw any exceptions after 24 hours of running ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found