arkane-systems / Arkane.Zeroconf

A Zero Configuration Networking library for .NET.
Other
3 stars 5 forks source link

Fix locking the serviceTable #9

Closed 0xced closed 1 year ago

0xced commented 1 year ago

Using a SemaphoreSlim instead of locking (which was erroneously implemented, locking once on this and once on this.serviceTable).

Using a SemaphoreSlim prevents the following exception:

System.Threading.SynchronizationLockException: Object synchronization method was called from an unsynchronized block of code. at void System.Threading.Monitor.Exit(object obj) at IEnumerator ArkaneSystems.Arkane.Zeroconf.Providers.Bonjour.ServiceBrowser.GetEnumerator()

Also, the this.serviceTable.ContainsKey() check are not necessary.