View previous topic :: View next topic |
Author |
Message |
EricTheViking
Joined: 17 Dec 2008 Posts: 24
|
Posted: Fri Sep 30, 2011 1:36 pm Post subject: Evaluation monitor strangeness... |
|
|
I've been writing some code that uses authenticated licenses and have experienced some wierdness with the EvaluationMonitor.
My application runs on a server and is a simple winForms app. There is a timer on the app that polls evaluationMonitor.DaysInUse to see how many days of the trial period are remaining and displays it on the form for the user.
The timer runs every 2 seconds.
I've been testing the licensing code by winding the clock forward and observing the DaysInUse value change.
The wierd thing is sometimes I launch the app the the days in use is correct (say 5 days). Other times i load the app the days in use is zero, then 10 seconds later it jumps to 5 days.
I also have a Windows Service running on the server that checks the evaluationMonitor.DaysInUse every few seconds and when the service is running the problem is worse (happens more frequently).
Do you know what might cause the DaysInUse property of the evaluation monitor to fluuctuate between two values like this? It's almost as though it's reading the value from two different sources? |
|
Back to top |
|
|
EricTheViking
Joined: 17 Dec 2008 Posts: 24
|
Posted: Fri Sep 30, 2011 10:28 pm Post subject: |
|
|
Some more info for you...
I will try not to refer to any code internals here, but if I do feel free to moderate/edit this post as appropriate. If I'm being too abstract let me know and I'll PM you.
I've been using the registry evaluation monitor, it turned out that I had about half a dozen zombie entries in the registry corresponding to my evaluation monitor. When creating a new evaluation monitor it was sometimes choosing a stale (zombie) entry in the registry.
Even if I cleared out the duplicate entries, duplicates would creep back in.
This happened most regularly when I ran the service and the winforms app at the same time. Two processes creating new registry evaluation monitors seems to cause duplicate registry keys. This looks like an inter process race condition and wrapping both my calls to create the evaluation monitor with a named mutex (inter process synchronisation) reduces the likelihood of duplication.
However the duplication also seems to creep in when I'm changing my system clock during testing. If I wind the clock forward a day or two it can cause a duplicate registry entry.
I'm still testing things here and am starting to get the hang of how the evaluation monitor works, but thought i'd pass on this info in case it helps with your answer. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Oct 01, 2011 12:11 am Post subject: |
|
|
I think the issue probably is the concurrency. The Evaluation Monitor was designed to protect a single application not two separate applications both hitting it continually. I can see in this circumstance you are likely to get some race conditions which could cause the issues you describe.
I can't see any reason why changing the clock would have the effect you describe and we do have an extensive automated test script which checks the behaviour of the EvaluationMonitor when changing the clock forward and back. Are your service and application both running when this occurs? Do you get the same issue if you run one of the sample projects? _________________ Infralution Support |
|
Back to top |
|
|
EricTheViking
Joined: 17 Dec 2008 Posts: 24
|
Posted: Sat Oct 01, 2011 8:01 am Post subject: |
|
|
I will continue testing to see if the clock winding does i fact cause any problems in my scenario. If it does I will post back here.
Another of our products is a multi-instance application, so users can run multiple instances of the same winforms app at once. Since the evaluation monitor is only called at startup it is unlikely that concurrency would cause a problem, but if the apps were changed to poll the evaluttion monitor the race condition could occur, might be worth documenting this in the source code?
I think my main issue was that I didn't realise there is an overhead in creating new evaluation monitors. Am now going to change my architecture to avoid creating evaluation monitors on the fly, and will create them at application startup instead of at each poll, and will re-instantiate them periodically (perhaps daily) in the code. |
|
Back to top |
|
|
|