01-19-2007 07:56 PM
01-22-2007 04:23 PM
01-22-2007 08:19 PM
Thanks for the reply.
I cut and pasted the code you provided into a new Windows app and experienced the same behaviour as before. I created a "demo" showing the effect of the program on my system (CPU pegged for 1-1.5 seconds on each Connect()) call - is there an email address I can send this demo? It's about 3 megs.
A successful ping prior to connect might be an option - but I find it difficult to believe that creation of a network connection requires billions of operations... it seems more likely that the cpu is needlessly spinning... are we sure there isn't a tight loop within the constructor call that would benefit from a Thread.Sleep(100)?
Another caveat that I noticed is that the intrinsic time stamp that comes in on data reads is off by 5 hours (for example, if the local time is 2pm, the timestamp coming in will be 7pm... I'm GMT-5 hours, probably not a coincidence). Oddly, the network variable manager shows the correct time stamp on the data passing through.
Cheers,
Shea
01-22-2007 08:55 PM
The timestamp on the Data is Coordinated Universal Time (UTC) via the documentation. You can use DateTime.ToLocalTime() to convert to local time.
As far as the Connect() issue, I would try setting a smaller timeout when connecting. For example, Connect(TimeSpan.FromSeconds(1)). This might keep the function from blocking too long. By default the timeout is 10 seconds. So if you just call Connect(void) the timeout is taken to be 10 seconds.
Obviously, Connect() is taking ~2 seconds for you, so the long timeout is not coming into play because the function is finding out the variable doesn't exist before 10 seconds. A smaller timeout might expedite the function. However, this is a slipperly slope because if you have too small a timeout the function won't succeed even if the variable exists!