ThuCommix / Sharpex2D

2D GameEngine for Indie games with alot of features
http://www.sharpex2d.de
MIT License
47 stars 9 forks source link

In a heavily multithreaded scenario with lots of keyboard action, using DualThreadGameLoop, the foreach() in Keyboard.cs line 50 frequently fails with "System.InvalidOperationException: Collection was modified; enumeration operation may not execute" #8

Closed dlatikay closed 10 years ago

dlatikay commented 10 years ago

I changed the type of _lastkeystate and _keystate to "ConcurrentDictionary", and replaced calls to .Add() with .GetOrAdd(). This solved the issue (so far).

ThuCommix commented 10 years ago

Very interessting to see a solution for that.

dlatikay commented 10 years ago

// Would you be so kind, and create a commit for that?

I was about to, when I realized that you already committed the exact same patch I had prepared :-)

ThuCommix commented 10 years ago

Sorry, thought you were away for awhile :-D