开发者

better way to keep counter other than global variable?

I have a windows service that does some processing by subscirbing to Message Queue. I have to keep a counter how many times it has received the message and make that counter available on WCF service so other people can query it.

Is there any better way of doing this other than Gl开发者_高级运维obal Variable?


You can use a private static variable within your class. It almost amounts to the same thing, but at least can have limited exposure to the class it is declared in.

Just to point out that in either case (global/static) you will lose the count on a restart of the service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜