Background: There is a development for vehicle dynamics, as an attempt to add realistic behavior, calculation results are performed real time with 1:1 scale to real life, ie, 1 seconds in real life = 1 second in computing results.
Problem: Under Windows XP/Vista/7 and even MacOS, everything is working as expected, however in Windows 8 the application runs (what seems to be) exactly 2x times slower.
Details: Delays are performed by
System.Threading.Thread.Sleep((Int32)time_delta)
Being time_delta, calculated as needed to match 1:1 time ratio.
Under Windows 8, what it takes 1 second in real life is taking 2 seconds, I could however use time_delta/2.0f however seems like a dirty trick.
Question: Is there a proper way to fix that?
References: I searched and found that seems to be reported issues: Missing .NET features in Metro style application?
This link says http://msdn.microsoft.com/en-us/library/d00bd51t.aspx that Thread.Sleep is supported under Windows 8.
Thanks in advance.
Update: I was wrong, the Windows 8 delays are not exactly 2 times slower, the resolution for Sleep() seems to have changed dramatically and (at least under my test) is very variable, so I ended up using real-time adjusting each time I detected an offset, a bit CPU intensive but is working now.
您是否尝试使用TimeSpan(例如TimeSpan.FromSeconds(time_delta))代替Int32?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.