[Mono-list] Bug in Environment.TickCount
Jeffrey Stedfast
fejj at novell.com
Fri Jul 20 00:23:25 EDT 2007
from what I can tell reading the man page... you want to do this:
guint32 GetTickCount (void)
{
struct tms tms;
clock_t ticks;
if ((ticks = times (&tms)) == -1)
return 0;
#ifdef LINUX_KERNEL_2_6_0_OR_LATER
ticks -= (UINT_MAX - 300) * CLOCKS_PER_SEC;
#endif
#define MSEC_PER_SEC 1000
#define CLOCKS_PER_MSEC (CLOCKS_PER_SEC / MSEC_PER_SEC)
return (guint32) (ticks / CLOCKS_PER_MSEC);
}
On Thu, 2007-07-19 at 22:38 -0300, Thiago M. Sayão wrote:
> Hello!
>
> Enrironment.TickCount is supposed to return the miliseconds since the
> boot. For my surprise it was returning a negative number which should
> only happen on the 47th day of uptime.
>
> I did i fix (attached) but it doesn't seem 100% correct and i am not
> sure if it would work after some days.
>
> Since i'm coding a msn library and msn p2p protocol uses GetTickCount(),
> it's messing things for me!
>
> Can anyone take a look?
>
> Thanks!
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
More information about the Mono-list
mailing list