w250697116 / apns-sharp

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

service.close stack my program #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. using Notifications
2. when running the program it is send to my device the notifications 
   but stack forever on the line service.close()

Original issue reported on code.google.com by avn...@gmail.com on 3 Mar 2010 at 6:19

GoogleCodeExporter commented 8 years ago
Yes, I am experiencing the same problem. I can kill the service with Dispose(), 
but 
would rather close properly.

Original comment by champion...@gmail.com on 22 Mar 2010 at 10:44

GoogleCodeExporter commented 8 years ago
I'm not able to reproduce this here.  If you look at the code, .Close() in 
NotificationConnection is not much different than Dispose.  It just lets all 
the 
notifications be sent out before closing things up.

I suggest calling .Close() and then .Dispose() on the NotificationService in 
that 
order.  

Are you saying that .Close() never finishes?  I don't see any reason why it 
would not 
finish unless you keep queuing more notifications.  Make sure your code stops 
queuing 
notifications before you call Close.

Original comment by jond...@gmail.com on 27 Mar 2010 at 6:50

GoogleCodeExporter commented 8 years ago
The workerThread's workerMethod() loops while !disposed.  This flag is not set 
until
Dispose(); however, the Close() method attempts to Join() with the worker thread
before Dispose() is ever called.

changing Line 344 of NotificationConnection.cs to [while (!disposing && 
!closing)]
lets the workerThread know it needs to stop looping.

Original comment by bruce.we...@gmail.com on 6 Apr 2010 at 3:42

GoogleCodeExporter commented 8 years ago
@bruce.weber

Do you have the latest SVN source?  

Your line 344 does not match up, so I suspect you might have an older version.  

Anyways, there's only two loops in the workerMethod that would be causing the 
workerThread to not die:

NotificationConnection.cs:352 -> while(!disposing && !closing)
  This should abort just fine if .Close() is called

NotificationConnection.cs:356 -> while(this.notifications.Count > 0 && 
!disposing)
  This may take awhile to actually complete, but eventually notifications.Count will 
reach 0 as the next line is this.notifications.Dequeue() and a notification is 
only 
attempted to be sent as long as it hasn't been sent successfully, or it's been 
tried 
this.SendRetries number of times.  I can't see how this loop would be causing 
issues 
either.

I'm guessing this is a non-issue and has been fixed since whatever version 
others who 
are experiencing this are using.

Original comment by jond...@gmail.com on 6 Apr 2010 at 3:53

GoogleCodeExporter commented 8 years ago
Quick update, I took a look at the revision history, and if you look at 
NotificationConnection.cs in revision 18, line 344 (which you refer to) is 
"while 
(!disposing)".  In revision 19, line 344 changes to: "while (!disposing && 
!closing)" 
which is your suggested fix.

So, please update your source code to the latest version.

Here are the revision details for 19:
http://code.google.com/p/apns-sharp/source/detail?r=19

Original comment by jond...@gmail.com on 6 Apr 2010 at 3:57

GoogleCodeExporter commented 8 years ago
I am getting the same problem with service.close() method. It is never ending. 
But my code is updated, I use "while (!disposing && !closing)" in 
NotificationConnection.cs.
It just get stuck at "workerThread.Join();" at 286 line.

Original comment by goutam.r...@gmail.com on 2 Sep 2010 at 9:35