Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

GetServiceAsync is not thread safe #51

Open
cprice70 opened this issue Jul 1, 2015 · 0 comments
Open

GetServiceAsync is not thread safe #51

cprice70 opened this issue Jul 1, 2015 · 0 comments

Comments

@cprice70
Copy link

cprice70 commented Jul 1, 2015

GetServiceAsync crashes with the following exception, it appears that the collection is being modified at the same time that it is trying to enumerate the services. The exception happens when this line is called

var s = device.Services.First (x => x.ID == id);

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException (ExceptionResource resource) [0x0000b] in :0
at System.Collections.Generic.List1+Enumerator[Robotics.Mobile.Core.Bluetooth.LE.IService].MoveNextRare () [0x00016] in <filename unknown>:0 at System.Collections.Generic.List1+Enumerator[Robotics.Mobile.Core.Bluetooth.LE.IService].MoveNext () [0x00050] in :0
at System.Linq.Enumerable.First[IService](IEnumerable1 source, System.Func2 predicate, Fallback fallback) [0x00026] in :0
at System.Linq.Enumerable.First[IService](IEnumerable1 source, System.Func2 predicate) [0x00007] in :0
at Robotics.Mobile.Core.Bluetooth.LE.Extensions+c__AnonStorey1.<>m__1 (System.Object sender, System.EventArgs e) [0x0002a] in /Users/cprice1/Projects/Monkey.Robotics/Source/Platform Stacks/Robotics.Mobile.Core/Bluetooth/LE/Extensions.cs:78
at --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in :0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in :0
at System.Runtime.CompilerServices.TaskAwaiter`1[Robotics.Mobile.Core.Bluetooth.LE.IService].GetResult () [0x00000] in :0
at IDS.BluetoothAdapter+c__async0.MoveNext () [0x000a4] in /Users/cprice1/Projects/Control/Control/IDS/IDS.BluetoothAdapter.cs:175
at --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in :0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__1 (System.Object state) [0x00000] in :0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant