System time(minute) change event doesn't raise per minute.

G

Guest

I wrote the following code to write the current datetime into a txt file per
minute in .Net CF2.0 version:

SystemState s = new SystemState(SystemProperty.Time);
s.Changed += new ChangeEventHandler(s_Changed);

void s_Changed(object sender, ChangeEventArgs args)
{
FileStream fsMyfile = new FileStream("\Program Files\Sender\1.txt",
FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
swMyfile.WriteLine("CurrentDateTime:" + DateTime.Now.ToString());
swMyfile.Flush();
swMyfile.Close();
}

I wrote this code according to the sample in WM6 SDK.
But, after few hours, I checked the txt file, it didn't write the system
time per minute.
The Actual Results as follow:
CurrentDateTime:07-6-30 17:37:02
CurrentDateTime:07-6-30 17:38:02
CurrentDateTime:07-6-30 17:39:02
CurrentDateTime:07-6-30 19:03:38
CurrentDateTime:07-6-30 19:04:03
CurrentDateTime:07-6-30 19:05:03
CurrentDateTime:07-6-30 19:10:51
CurrentDateTime:07-6-30 19:11:02
CurrentDateTime:07-6-30 19:12:02
CurrentDateTime:07-6-30 19:13:02

During 07-6-30 17:39:02 to 07-6-30 19:03:38, I didn't use my mobile. So, I
think, maybe it's the problem.

Then I tried the System.Threading.Timer also. It's same problem as above.
When the screen turn off, then the system will not raise the timer tick event
again.

I don't know it's the .Net CF2.0's bug or not.

So, I submit it here.

Could you help me on it?

Thanks a lot!

=============================
btw, What I want to do is to monitor a directory, If got any file, then
process it and cut it to other folder.

It looks like a Service. Right?
I found a lot of documents that talk about how to create Service in VC++,
but, I don't know anything about VC++, I just know C#.

Could you teach me to create a service by C#?
 
P

Paul G. Tobey [eMVP]

If the device suspends, of course no code is going to be running; the device
is suspended.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top