Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: 3.5 Source Code for release 2013.1.8?

$
0
0
Good Morning.

Simply using a VS2010 compiled version is probably the right solution, as it seems several folks are doing it, but it bugged me not knowing WHY seemingly correct code worked differently between compilers.

'this.Session.MessageReceived' is declared
 internal event EventHandler<MessageEventArgs<Message>> MessageReceived;
The Visual Studio 2008 and 2010 C# compilers treat the 'event' access modifier differently. See "Visual C# 2010 Breaking Changes" at http://msdn.microsoft.com/en-us/library/ee855831(v=vs.100).aspx; it talks about changes in Event synchronization.

Looking at the CIL for the VS2008 compiled version, I see the 'synchronized' attribute on the Renci.SshNet.Session::add_MessageReceived Method. That attribute is NOT present in the VS2010 version. From the CLI standard (ECMA-335) "Synchronized methods. A lock that is visible across threads controls entry to the body of a synchronized method. For instance and virtual methods the lock is associated with the this pointer."

So basically, the 'synchronized' attribute in the VS2008 version is equivalent to 'lock(this)' on the Session object. Well, Session.Connect wraps the whole connection attempt and key exchange in a 'lock(this)', so the delegate add blocks until the key exchange attempt times out and Session.Connect exits.

The rest of the code seems to handle event synchronization in accordance with the VS2010 recommendations, so it would indeed seem safer to go with VS2010, rather than re-work it for VS2008.

Matt

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>