471,337 Members | 1,129 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Windows Service - strange stopping behaviour

Hi - any help with this would be greatly appreicated - it has already had me
confused for a good few hours!

I am using Visual Studio 2003 and the .NET framework 1.1.

I have a C# Windows Service, with my own class extending from ServiceBase in
the normal fashion. The service starts a remoting object (WKO and
singleton) which many clients can then make calls on. Clients may also
register with events on the server such that the server will inform clients
when certain actions occur.

This all works fine and clients are appropriately notified when the server
fires the events.

However, I would like the clients to also be informed when the service is
stopping - and so I thought that firing an event in the service's overridden
OnStop() function would be ideal for this. I can see that the multicast
delegate on the server has the delegates to call upon so it seems the
clients have successfully registered their interest in the service shutting
down. I can prove this by firing the event at any time and all works well.
However, the strange behaviour I am seeing is that as soon as I break on
entry to the OnStop() method - the place where I need to fire the event -
the event/delegate member variable is null - someone (not me!) has clearer
all the delegates - so it appears that no one is interested in the service
shutting down - when there really are interested parties.

Does anybody know why this is happening? The service has member member
variables - some value types, some reference types, and they are all still
present and correct on entry to the OnStop() function, but any event member
variables have been cleared and are nulls.

Is this possibly as designed for some reason and Ive missed some piece of
documentation saying that events are cleared by the time the framework calls
OnStop for you?

Any help greatly appreciated.


Jul 21 '05 #1
0 1380

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Steve Long | last post: by
9 posts views Thread by SP | last post: by
reply views Thread by Daniel O'Brien | last post: by
6 posts views Thread by D | last post: by
reply views Thread by SenthilVel | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.