Help Creating A Scheduled Task

M

MDB

Hello All, I really need help creating a scheduled task. I have tried
using CeRunAppAtTime and CeSetUserNotificationEx however have not had any
luck. The problem is that it does work however, it is very inconsistent.
One day, 90% of the devices with run the task and then one day only 20% will
run it. Can anyone point me in the right direction or recommend anything.
Basically what I am doing is having a application run every day at 5:00 am
to get any updates for my main application.


Thanks In Advance
 
A

Alex Feinman [MVP]

CeRunAppAtTime generally works. One reason it may fail for you (and I'm
shooting in the dark since you have not provided much details) is that if
the application being launched is a CF application and it was already
running in the background, the second copy will not be launched. Instead an
existing one will attempt to go into foreground
 
M

MDB

It is a CF application however, it is not the same one. I have one main
application that is used, everytime this application is started, it calls
the usernotifications.runapplicationtion that I found here:

http://samples.gotdotnet.com/quickstart/CompactFramework/doc/notifications.aspx

Here is how I call it:

string path;
path =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
);

//First reset task time
DateTime dtNextRunTime =
Convert.ToDateTime(DateTime.Now.AddDays(1).ToShortDateString() + "
05:00AM");
MyApp.Classes.UserNotifications.RunApplication(path +
"\\FTPTask.exe","",dtNextRunTime);

All my FTPTask.exe does is set a Token File and then warm boots the device
to clear everything out of memory. Then when the main application starts
up, it looks for this token file.

Here is what my FTPTask.exe looks like:

static void Main()
{
string path;
path =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
);
File.Create(path + "\\update\\FTP.tok");

Rebootapi reboot = new Rebootapi();
reboot.SoftReset();
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

public class Rebootapi
{
[DllImport("Coredll.dll")]
extern static int KernelIoControl(
int dwIoControlCode,
IntPtr lpInBuf,
int nInBufSize,
IntPtr lpOutBuf,
int nOutBufSize ,
ref int lpBytesReturned );

[DllImport("Coredll.dll")]
extern static void SetCleanRebootFlag();

public void SoftReset()
{
int IOCTL_HAL_REBOOT = 0x101003C;
int bytesReturned = 0;

// Do not use SetCleanRebootFlag()
KernelIoControl(
IOCTL_HAL_REBOOT,
IntPtr.Zero,
0,
IntPtr.Zero,
0,
ref bytesReturned );
}
}


Any ideas? Although I am setting this by calling the
CeSetUserNotificationEx (though usernotifications.runapplicationtion ) could
something be clearing it out of memory after I set it?
 

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