Starting MCE EPG download after MegaEPG

Hi Igor,

My name is Yossi and I am a programmer my self (more a real-time programmer, and a bit of Windows...)
I know that the above feature (starting MCE EPG download after MegaEPG finished) was requested few times ago and you've answered that you don't know how make the MCE to start the download process, so I think I have a solution to that problem !!!

I made some research over the net and here is how I think it can be done:
Some background (this related to MCE 2005, but it probably similar in Vista):
a) There is process named "ehSched.exe" - this process is responsible for all the MCE timing scheduling: recording & EPG download
b) There is a registry key that the above process is using to know when to download the EPG
c) The process is grabbing the above registry key for the time only when it is starting. So while this process is already running, if you change the time in the registry key you don't influence the actual scheduling until the next time the process is re-started.
Read more info regarding this in the following link:
http://thegreenbutton.com/forums/thread/21568.aspx

As a start, let's assume the following:
a) the current time is 18:55
b) the MegaEPG is set to download at 19:00 - using the Win Scheduler of course...
c) the MCE is set to download the EPG at 23:00 (as a safeguide, later on you will understand why it is like that, and how to control it)

Here are the steps:
1) When time will be 19:00 MegaEPG will launch
2) MegaEPG Download all the program's guide as usual
3) When MegaEPG finished downloading the guide, it is stopping the "ehSched.exe" process using Windows API
4) Now MegaEPG read the current time and set the registry key time to be something like 5 minutes later (using the calculation examples in the link above) - 5 minutes is a "safe-guard", 2 minutes could be enough as well
5) Now MegaEPG should re-start the "ehSched.exe" process (either by starting MCE or by starting it separately if you find a way). Note that MegaEPG still need to be run and not exit yet
6) 5 minutes later (or 2) - the MCE shall download the EPG
7) MegeEPG shall wait for the MCE to finish update the EPG (I think that another 5 minutes should be enough)
8) After enough time elapsed, MegaEPG shall change the registry key back to 23:00 of the next day (this is a safe-guard to prevent that the MCE will try to download the EPG in the middle of the actual guide download in the next day)
9) Close "ehSched.exe" process - if you launch the full MCE then you need to close the MCE first, and then kill the process
10) restart the ehSched.exe process - again, either by launching the process if you figure out how, or by launching the whole MCE - this is for the new time to be used until next time EPG will launch
11) if you launch the full MCE - then just close the MCE without killing the ehSched.exe process
12) exit MegaEPG
13) all done...

What do you think about this idea? Can you implement this?

Thanks,
Yossi.G.

P.S. 2 more small ideas
1) Add the version number In the MegaEPG title so when someone would like to make sure which version he owns then he can see it when it's running
2) Fix the version number in the readme (it is still showing 1.16)

Yossi, thank you for your

Yossi, thank you for your suggestion!

I considered it already but found killing the ehSched process to be a bad solution. It might hurt the scheduled recordings and restarting of the MCE might hurt the user experience when EPG updating is happening in the background when using the media center. I'm searching for a more clean way to cause the media center to update the EPG.

Regarding the versions: the MegaEPG displays the version in the command line version. For the windowed version you can use megaepgw --version to check out the version. 

1.16 is the version of the readme itself. I agree it's confusing and should represent the global version. I will fix that. 

a) Of course the ehSched is

a) Of course the ehSched is responsible for the EPG time download and the recordings.
But as I suggested the ehSched will be "killed" for a very short duration - you need to kill it, change the registry key and immediately re-start the process, this could be done in a matter of seconds so I find it hard to believe that will hurt the scheduled recordings.

b)Regarding the restarting of the MCE - I agree that if the user is currently working with MCE opened and you want to restart the MCE (to re-start the ehSched) then you might hurt the user experience.
An idea - Before trying to re-start the MCE you can check if the MCE application is already running, in that case, do not try to do it.
I agree that a cleaner way would be much better, like calling a specific Windows API to update the EPG, but I don't believe that Microsoft has given that kind of API in their software...
I will also try to think of a way to do it cleaner but I think that the above option is better than nothing...You can have it as an option to the MegaEPG in which the user configures the SW on the config screens.

c) About the version number - the "--version" is a nice option but if you can add the version number into the program title it will easier.

Thanks, sounds reasonable. I

Thanks, sounds reasonable. I put them in the todo list.