NetSha.Hash method isn't thread safe. (I have got the CryptographicException)
Although it is protected in NetPeer.Internal with lock , two NetPeers can call
this method simultaneously.
Moreover according to MSDN (
http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx
)
"Any public static (Shared in Visual Basic) members of this type are thread
safe. Any instance members are not guaranteed to be thread safe."
ComputeHash is an instance method, therefore not thread safe.
Solution:
Since this method is needed primarily in NetPeer.InitializeNetwork which is
called only once per NetPeer, this method can be surrounded with simple lock.
Original issue reported on code.google.com by NN1436401@gmail.com on 26 Sep 2010 at 11:01
Original issue reported on code.google.com by
NN1436401@gmail.com
on 26 Sep 2010 at 11:01