Question : how to get the milliseconds from datetime in dotnetcompact framework

Iam using dotnet compact framework.
I am logging the error messages using log4net dll.
iam using the following code.
if (transferLogger.IsDebugEnabled)
            {
                transferLogger.Debug("BaseTransferPresneter Start Time:" + System.DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss:fff tt"));
            }

The out put is

2009-12-08 15:35:10,000 [1090261] DEBUG TransferApplicationLogger [(null)] - BaseTransferPresneter Start Time:08-12-2009 03:35:10:000 PM.

in the above output the milliseconds is coming 000.
how to get the Milliseconds in dotnetcompact framework.
pls give me the code to get the milliseconds from  System.DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss:fff tt")); .

Answer : how to get the milliseconds from datetime in dotnetcompact framework

hi,
I guess, for performance testing you need the milliseconds value right?

you can use like below,
int result = Environment.TickCount & Int32.MaxValue;
 transferLogger.Debug("BaseTransferPresneter Start Time:" + System.DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss") + "Tick count : " + result);

//Your code to test performance

transferLogger.Debug("BaseTransferPresneter End Time:" + System.DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss") + "Tick count : " + Environment.TickCount & Int32.MaxValue - result);

Environment.TickCount :Gets the number of milliseconds elapsed since the system started [from Msdn].
So just subtract he previous time from the current time will give you the total milli seconds elapsed.... (you dont need to calculate from the Datatime value)

Regards
Deepu

Regards
Deepu
Random Solutions  
 
programming4us programming4us