TReKiE / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

MSNPSharp.NSMessageHandler.OnSignedOff fired multiple times #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a Trace.WriteLine to MSNPSharp.NSMessageHandler.OnSignedOff.
2. Start the DotMSNClient from Visual Studio.
3. Connect.
4. Once connected, disconnect by selecting Offline from the dropdown.

What is the expected output? What do you see instead?
The expected output is a single sign-off notification in the Output tab of 
VS. Instead, the notification is listed twice.

What version of the product are you using? On what operating system?
Rev 456 (trunk), Windows XP Pro.

Please provide any additional information below.
Note that multiple threads seem to be involved in this issue. This issue is 
compounded by further problems, such as a System.ObjectDisposedException 
(possibly thrown as a result of SocketMessageProcessor.Disconnect getting 
called multiple times).  

Since this issue seems to be some sort of threading issue, I thought I 
would point out that there are a lot of places in the code base that use 
Thread.Sleep(). I would recommend refactoring out the Thread.Sleep() calls 
such as the one in NSMessageProcessor.Disconnect(). These hard-coded 
timeouts should typically be avoided, a decent (though somewhat harsh) 
article I came across on this is 
http://msmvps.com/blogs/peterritchie/archive/2007/04/26/thread-sleep-is-a-
sign-of-a-poorly-designed-program.aspx.

On a related note, I noticed that MSNPSharp.NSMessageProcessor.DispatchMessage 
uses a copy of the array to 
avoid synchronization issues, while other places in the code base make use 
of the lock keyword. Perhaps DispatchMessage should be using "lock" instead 
of an array copy?

Original issue reported on code.google.com by its....@gmail.com on 1 Nov 2008 at 2:07

GoogleCodeExporter commented 9 years ago
Aha, thanks for your report, let me see..

Original comment by freezing...@gmail.com on 1 Nov 2008 at 6:56

GoogleCodeExporter commented 9 years ago
Cannot reproduce this problem

Original comment by freezing...@gmail.com on 3 Nov 2008 at 6:03

GoogleCodeExporter commented 9 years ago
I tried this again with the latest code from SVN and the Example client, and it 
still 
happens. All I did is add the following line of code to NS15MessageHandler.cs:

Line 790: Trace.WriteLine("NSMessageHandler: OnSignedOff");

Then I clicked Run in VS, clicked Connect, waited about 15 seconds after 
connection, 
and then selected Offline.

Here's the exact contents of the Outputs tab in VS from when I clicked Offline:

NSMessageProcessor: Outgoing message:
OUT
NSMessageProcessor: Disconnected
A first chance exception of type 'System.ObjectDisposedException' occurred in 
System.dll
NSMessageProcessor: Disconnected
NSMessageHandler: OnSignedOff
NSMessageHandler: OnSignedOff
NSMessageProcessor: Outgoing message:
OUT
NSMessageProcessor: Disconnected
NSMessageProcessor: Outgoing message:
OUT
NSMessageProcessor: Disconnected

As you can see, there are two "NSMessageHandler: OnSignedOff" lines instead of 
just 
one. You can also see the object disposed exception I was talking about.

Does this information help you reproduce this issue?

Original comment by its....@gmail.com on 3 Nov 2008 at 10:07

GoogleCodeExporter commented 9 years ago
Hi, everything is ok on my computer. Are you sure you are running the latest 
code?

Original comment by freezing...@gmail.com on 4 Nov 2008 at 3:32

GoogleCodeExporter commented 9 years ago
NSMessageHandler: Notification received : NSMessageProcessor: Outgoing message:
OUT
NSMessageProcessor: Disconnected
A first chance exception of type 'System.ObjectDisposedException' occurred in 
System.dll
NSMessageHandler: OnSignedOff
NSMessageProcessor: Outgoing message:
OUT
NSMessageProcessor: Disconnected
NSMessageProcessor: Disconnected

Original comment by freezing...@gmail.com on 4 Nov 2008 at 3:34

GoogleCodeExporter commented 9 years ago
Thanks for looking at it again - I did get the latest codebase from SVN and 
recompiled, but once again VS wasn't recompiling everything it should have 
been. I 
manually removed the obj and bin directories from the two projects, recompiled, 
and 
now I see the same thing as you. Thanks, I'll make sure I do a "clean" next 
time I 
update my local source.

Original comment by its....@gmail.com on 4 Nov 2008 at 10:00

GoogleCodeExporter commented 9 years ago

Original comment by hepha...@gmail.com on 23 Jan 2009 at 5:36