In this article we will focus on how to start an application or system by the schedule time in windows mobile devices. In this scenario I’m going to work with .net compact framework 3.5 and Windows mobile latest Device 6.1.4 to test it.
Actually this is not hard to do in windows mobile, but there are some limitations because .net compact framework is not like the full .net framework. Since we are talking about scheduling, Time is the key factor. In Window CE operating system SystemFileTime is usually preferred rather than normal date and time.
1. Windows Mobile 6 SDK
2. Windows Mobile 6 Professional Emulator.
3. Visual Studio 2008
First we want to understand SystemFileTime because we’re going use this to schedule time implementation. So what is SystemFiletime? It is related to Operating system time and is also a structure to maintain the time object in the memory. In other words it contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). You can find more details on FileTime here http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx.
Now we move to our scenario: I want to start an application at a scheduled time using the parent System specifically I’m going to start pocket word at a scheduled time. For this I created a very simple user interface.
It's a very simple GUI where I’ve added a simple menu with File and about. Under the File I have a submenu called Start. When I click the Start I’m going to set my schedule time to FileTme and then to another Operating system function.
Before coding we must understand the Platform invoke services in .Net framework and .Net compact frame work. Next I’m giving a small intro with details about P/Invoke.
What is the P/Invoke?
.Net technology has wonderful feature access operating system functions within it. When we try to access the OS function within the Managed code, Microsoft calls the P/Invoke service. Look below:
Platform Invoke Service.
Click the link below to get more info on P/Invoke.
I hope you now understand P/Invoke. Now you can raise another question: How do we call the function within.Net. This is very simple, just view the next example and you’ll see the answer to that question.
First I’m going to write code to P/invoke some function to use my example.
Notice how we access the operating system function within the .net by the P/Invoke services.
we must use the static extern keyword for this purpose but that’s not difficult if you know the operating system function name. Visit the site below to view the .net syntax.
Now I’m going to move to my example.
I’m going to initilize a few variables to use my upcoming code.
This is basic level code I’ve written for the menu click event but here you must understand some key points.
First I ‘m setting start time, then I’m converting normal time to filetime on the line long fileStartTime = startTime.ToFileTime(); then I’m going to get the localFiletime using the Filetime.
I’m going to get localfiletime using the FileTimeToLocalFileTime function. Now we call another function, set my application which I want to start and when I want to start it.
Now view the results:
I set 30 seconds to schedule time to lunch IE after 30 second resalt are like this.
I discussed how to launch and start an external application by the schedule based time. It’s very useful when we need work in autolaunch scenarios and I hope this article is useful to mobile developers.
My name is RRaveen, currently living and working in Singapore. Ii am highly focusing on to provide better Solutions to business problems which are commonly an organization facing, retrieve information on time using information technologies.Since i loves windows mobile technology design and implementation business applications which is based on C#.And my other specializations are Asp.net,WPF and WCF .
i have been working on many back ends which are Mysql,Sqlserver and Oracle/PL/SQL/TOAD hands on experience more than 3 and a half year.