In the method monitorCallback() I write a the time to text file. after writing the file I check the FileInfo of file and print it.
I have got the following result:
time = 16/08/2009 14:01:46, mili = 307
time = 16/08/2009 14:01:51, mili = 291
time = 16/08/2009 14:01:56, mili = 291
time = 16/08/2009 14:02:01, mili = 291
time = 16/08/2009 14:02:06, mili = 291
time = 16/08/2009 14:02:11, mili = 291
I can't understand why the time is change but the Millisecond is stay fixed
private Timer monitor;
public Window1()
{
InitializeComponent();
monitor = new Timer(monitorCallback, null, 0, 5000);
}
private void monitorCallback(object state)
{
string path = @"C:\Test.txt";
Stream stream = File.OpenWrite(path);
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine(DateTime.Now);
writer.Close();
FileInfo fileInfo = new FileInfo(path);
Dispatcher.Invoke(DispatcherPriority.Normal,
new Action(delegate
{
Debug.WriteLine( "time = " + fileInfo.LastWriteTimeUtc + ", mili = " +
fileInfo.LastWriteTimeUtc.Millisecond);
}));
fileInfo = null;
}