What’s likely happening is that SignalData
is indirectly changing the subscribers dictionary under the hood during the loop and leading to that message. You can verify this by changing
foreach(Subscriber s in subscribers.Values)
To
foreach(Subscriber s in subscribers.Values.ToList())
If I’m right, the problem will disappear.
Calling subscribers.Values.ToList()
copies the values of subscribers.Values
to a separate list at the start of the foreach
. Nothing else has access to this list (it doesn’t even have a variable name!), so nothing can modify it inside the loop.
Related Posts:
- What does a lock statement do under the hood?
- What is C# equivalent of
- WCF vs ASP.NET Web API
- What is the best way to iterate over a dictionary?
- Proper way to initialize a C# dictionary with values
- The HTTP request was forbidden with client authentication scheme ‘Anonymous’. The remote server returned an error: (403) Forbidden
- Get dictionary value by key
- Get single value from dictionary by key
- How do you sort a dictionary by value?
- Thread-safe List
property - How to update the value stored in Dictionary in C#?
- windows could not start service on local computer error 5 access is denied
- Get dictionary key by value
- The remote server returned an error: (405) Method Not Allowed. WCF REST Service
- C# Convert List
to Dictionary - does not implement interface member
- C# Dictionary get item by index
- .Net 4.8 Support for Windows 10 ends in 26 days?
- How can I convert String to Int?
- How to find child of a GameObject or the script attached to child GameObject via script
- Process cannot access the file because it is being used by another proess
- How to convert JSON to XML or XML to JSON?
- Virustotal Trapmine suspicious.low.ml.score
- What is the difference between declarative and imperative paradigm in programming?
- Group by in LINQ
- Convert int to string?
- Unity OnTriggerEnter2D not registering
- How to Sort a List
by a property in the object - The page was not displayed because the request entity is too large on IIS
- How to open .dll files to see what is written inside?
- how does Request.QueryString work?
- C# Java HashMap equivalent
- System.Net.Http: missing from namespace? (using .net 4.5)
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- WFP Grid: MouseRightButtonDown firing occuring BEFORE SelectionChanged on grid. Causing syncing issue
- Can’t add script component because the script class cannot be found?
- Extension methods must be defined in a non-generic static class
- Return multiple values to a method caller
- Regex that accepts only numbers (0-9) and NO characters
- Deserialize JSON with C#
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- How to resolve this System.IO.FileNotFoundException
- What is WebResource.axd?
- Fire ontextchanged() event of an asp:TextBox via Javascript
- C# Gridview CheckBox Field VS (Template Field + CheckBox)
- Extension methods must be defined in a non-generic static class
- Convert char to int in C#
- The remote server returned an error: (403) Forbidden
- How do I encode and decode a base64 string?
- How to add a delay for a 2 or 3 seconds
- How to keep console window open
- Tree data structure in C#
- The calling thread cannot access this object because a different thread owns it
- Convert JSON String To C# Object
- What is 0x10 in decimal?
- Visual Studio: The Operation could not be completed. The parameter is incorrect
- Member ‘
‘ cannot be accessed with an instance reference - Sequence contains no matching element
- when do you need .ascx files and how would you use them?
- How to open a new form from another form
- C# – How to convert string to char?
- The entity type
is not part of the model for the current context - Index was out of range. Must be non-negative and less than the size of the collection parameter name:index
- Is dependency injection useful in C++
- Parse Json string in C#
- Recommendation for C# Matrix Library
- System.BadImageFormatException: Could not load file or assembly
- Deep cloning objects
- Regular expression “^[a-zA-Z]” or “[^a-zA-Z]”
- .NET graph library around?
- Input string was not in a correct format
- There is no ViewData item of type ‘IEnumerable
‘ that has the key country - C# – Rounding Down to Nearest Integer
- How to write a comment in a Razor view?
- Verify a method call using Moq
- XmlSerializer – There was an error reflecting type
- Run Command Prompt Commands
- Cannot implicitly convert type ‘System.Collections.Generic.List< >‘ to ‘System.Collections.Generic.IList< >‘
- How can I wait for a thread to finish with .NET?
- How do I exit a WPF application programmatically?
- Remove duplicates from a List
in C# - How to deserialize xml to object [duplicate]
- OnCollisionEnter is not called in unity
- The name ‘ViewBag’ does not exist in the current context – Visual Studio 2015
- How to create a new object instance from a Type
- Is there an equivalent to the C# “var” keyword in C++/CLI?
- Differences between SFTP and “FTP over SSH”
- When should I use a List vs a LinkedList
- Remove punctuation from string with Regex
- Unity – How to stop Play Mode in case of infinite loop?
- The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?
- Go To Definition: “Cannot navigate to the symbol under the caret.”
- Why am I getting an Exception with the message “Invalid setup on a non-virtual (overridable in VB) member…”?
- Is there a keyboard shortcut to maximize the Game window in Unity in Play Mode?
- IF Statement multiple conditions, same statement
- What is the easiest way to handle associative array in c#?
- What does the M stand for in C# Decimal literal notation?
- Iif equivalent in C#
- Convert an array to string
- is inaccessible due to its protection level