NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 45 46 47 48 49 … 93 Next »
Timers and the MVP

 
  • 0 Vote(s) - 0 Average
Timers and the MVP
cgmt
Offline

Member

Posts: 86
Threads: 14
Joined: Apr 2006
#1
2007-03-23, 08:30 PM
I am writing a Pluggin that is using a System.Timers and it fires every x seconds and when it does fire I need to refresh the screen as the background has changed. It works great on the main PC but not thru the MVP. I am just adding a handler in the activate event for the timer.Elapsed event... then in the handler I do the follwoing:
PluginHelperFactory.getPluginHelper.SetImage(x)
and I have even tried
PluginHelperFactory.getPluginHelper.ForceRepaint()

Anyone ideas would be appreciated..
Intel 3GH
MSI FSB 800 MHz
2GB2 DDR RAM
HD Sizes: 250GB, 500GB, 500GB
ATI Raedon 256 MB
2 Hauppauge PVR 150
Windows XP Pro SP2
Wireless 802.11g WEP
Wireless MVP
Wired MVP
GBPVR v1.2.9
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,765
Threads: 769
Joined: Nov 2003
#2
2007-03-23, 10:09 PM
A lot of this GDI+ gui stuff doesnt like to be done on background threads, which is what happens when you use these timers. You should really using a scheme that returns 'true' from needsRendering() each time it needs to be updated.
cgmt
Offline

Member

Posts: 86
Threads: 14
Joined: Apr 2006
#3
2007-03-24, 12:23 AM
So instead of using a timer, are you sugesting that I basically become "busy for a period of time while I check the needsrendering property and when I do need to do something based on an internal counter(timer) and need to be refreshed, jsut use that property as the item to check while doing a continuious loop instead of a timer... Thanks in advance for your help....

To make things simpler, how would you recomend something firing every 10 seconds?
Intel 3GH
MSI FSB 800 MHz
2GB2 DDR RAM
HD Sizes: 250GB, 500GB, 500GB
ATI Raedon 256 MB
2 Hauppauge PVR 150
Windows XP Pro SP2
Wireless 802.11g WEP
Wireless MVP
Wired MVP
GBPVR v1.2.9
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,765
Threads: 769
Joined: Nov 2003
#4
2007-03-24, 12:50 AM
Quote:So instead of using a timer, are you sugesting that I basically become "busy for a period of time while I check the needsrendering property and when I do need to do something based on an internal counter(timer) and need to be refreshed, jsut use that property as the item to check while doing a continuious loop instead of a timer...
No, thats not what I meant.

If your plugin is the active task, then GB-PVR will call needsRendering() once a second on your plugin. Usually this would return false, but if you want the screen updated, then you can return true. With this in mind, you could easily do something like:

declare a variable one the class to hold the last renderer time
Code:
private DateTime lastRenderTime = DateTime.Min;

add logic to the render method to updated it
Code:
public Image render(out bool requiresMoreRendering)
{            
     ...
     lastRenderTime = DateTime.Now;
     ...
}


Add code to needsRendering() to force update if the screen hasnt been updated in the last 10 seconds.
Code:
public bool needsRendering()
{
    if (lastRenderTime.AddSeconds(10) <= DateTime.Now)
        return true;
    return false;
}

There are lots of other ways this could be done, but most are just a variation on this theme.
cgmt
Offline

Member

Posts: 86
Threads: 14
Joined: Apr 2006
#5
2007-03-24, 02:45 PM
That works perfectly. Thanks for your help...
Intel 3GH
MSI FSB 800 MHz
2GB2 DDR RAM
HD Sizes: 250GB, 500GB, 500GB
ATI Raedon 256 MB
2 Hauppauge PVR 150
Windows XP Pro SP2
Wireless 802.11g WEP
Wireless MVP
Wired MVP
GBPVR v1.2.9
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode