C9Glax / OBSKorgNanokontrol2

Translates MIDI-Events from your KORG nanoKontrol2 to the OBS-web-socket
MIT License
14 stars 2 forks source link

System.InvalidOperationException #13

Closed smurphster closed 3 years ago

smurphster commented 3 years ago

I was really messing around with multiple sliders at once and caused this exception. Probably would never happen under normal conditions but figured if it's easy to fix, we might as well. I'll take a look at it tomorrow if you don't get to it first. image

System.InvalidOperationException HResult=0x80131509 Message=Collection was modified; enumeration operation may not execute. Source=mscorlib StackTrace: at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext() at nanoKontrol2OBS.Kontrol2OBS.EventClock.<>c__DisplayClass3_0.<.ctor>b__0() in C:\Users\devil\source\repos\OBSKorgNanokontrol22\OBSMidi\nanoKontrol2OBS\EventClock.cs:line 32 at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

smurphster commented 3 years ago

Since that code is multi-threaded, I bet one thread modified the collection while the other was in the foreach loop.

C9Glax commented 3 years ago

That is 100% what happened, maybe just make a copy and run the enumeration on that...

C9Glax commented 3 years ago

Should be a non-issue now, but reopen if it reoccurs