NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 30 31 32 33 34 … 93 Next »
Method to notify plugin of exit

 
  • 0 Vote(s) - 0 Average
Method to notify plugin of exit
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#1
2008-03-06, 06:10 AM
Is there a method similar to OnDeactivate() that is called when pvrx2.exe is closing?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#2
2008-03-06, 06:19 AM
Unfortunately no there isnt. The next version does have an event notification to let apps know that it's exiting though.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#3
2008-03-06, 06:23 AM
Awesome. I'll add that part after the next release then. I probably won't need it before then anyway. Thanks.
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#4
2008-03-09, 09:49 AM
sub Wrote:Unfortunately no there isnt. The next version does have an event notification to let apps know that it's exiting though.

Does 1.2.9 include this event notification? I couldn't see the event in GBPVR.Public.EventTypes, and nothing seems to be sent to IEventNotification. Am I doing someting wrong?
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#5
2008-03-09, 03:49 PM
Sorry, no it didnt get included in 1.2.9. I realised there would be some situations where the app wasnt going to know it was exiting, so I talked to whurlston and we solved his particular problem a different way.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#6
2008-03-10, 12:04 AM
sub is too kind. I was not setting isBackground = true on my threads so they were not closing with GB-PVR.
ralphy
Offline

Senior Member

Posts: 255
Threads: 51
Joined: Nov 2006
#7
2008-06-15, 06:20 AM
whurlston Wrote:sub is too kind. I was not setting isBackground = true on my threads so they were not closing with GB-PVR.
The thread.isBackground=true does allow the termination of the plugin when PVRX2 exits as mentioned previously, however, I am having some difficulties in getting the ExternalDisplay plugin to terminate properly by executing some cleanup code. Hopefully, the gurus out there can provide some guidance on what's wrong with the code

in pseudo code
Code:
public class GBPVRStopPluginTestTask: IEventNotification  
  {

    static private bool stopRequested  = false;
    private Thread t;

    public   GBPVRStopPluginTestTask()
    {
        if (PluginHelperFactory.getPluginHelper() == null  ) return;
        DoStart();

       // set up a 'do nothing' Timer to keep this running in the same thread, and allow the destructor to be caught on class exit - This is the only way I was able to get the plugin to terminate
        System.Timers.Timer NullTimer = new System.Timers.Timer(60000);
        NullTimer.Elapsed += new System.Timers.ElapsedEventHandler(DoNothing);
        NullTimer.Start();
        NullTimer.Enabled = true;
        return;
     }

/// <summary>
/// This 'Do Nothing' method is just to keep the main thread running
/// so that the Destructor is called when t.Isbackround=true.
/// </summary>
private void DoNothing(object sender, EventArgs e)
{
    return;
}

    ~GBPVRStopPluginTestTask()
    {
        // This is only called if the doNothing method is used, and IsBackground=true
          Stop();
     }

      public void DoStart()
      {
          // startup code
          stopRequested = false;
          t = new Thread(new ThreadStart(Run));
          t.Priority = ThreadPriority.Lowest;
          t.IsBackground=true;
          t.Name = "StopPluginTest";
          t.Start();
      }

    public void Run()
    {
        while (!stopRequested)
        {
    // This is where the work is done
    // DoWork();
              Thread.Sleep(250);
        }
        // clean up code
    }

      private void Stop()
      {
              stopRequested = true;
              while (t.IsAlive)
              {
                  Logger.Verbose("StopPluginTest.DoStop(): Background thread still alive, waiting 100ms...");
         Thread.Sleep(100);
              }
        
              t = null;
     // cleanup code
      }


  }
}

Debugging suggest that when PVRX2 exits, the class destructor gets called, and the Stop() method is correctly called.

Although stopRequested is set to true by Stop(), the while(!stopRequested) loop in Run() does not appear to exit, and the cleanup code in the Run() never gets to execute. It appears as though this thread simply terminates, rather than exiting the loop, and then running the cleanup code.

But t.IsAlive in Stop() continues to return ‘true’, so Stop() loops several 100’s ms, and never gets to run any of the cleanup code because it never breaks out of the while(t.IsAlive) loop.

I’ve lost count of the different combinations of threads and isBackgound=true/false I’ve tried. Perhaps I’m stuck in the trees and forgotten what the forest is supposed to look like and there’s something fundamental that’s not being done correctly.

Compilable code with some extras:
[SIZE="1"]Silverstone GD01S-MXR (three dead rows of pixels in the LCD and defective remote control), Power: Zalman ZM460B-APS (blew up - can't remember what's there now); CPU: Pentium D 3.2 GHz with Asus V72 Cooler; MD: Asus P5LD2 Deluxe 2048MB,
WDC WD10EADS 1TB Data, 320GB System, Asus EN9400GT Silent 512MB, Hauppauge HVR 1300,
XP Home SP3, GB-PVR 2.0, ExternalDisplay v0.3[/SIZE]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 2,738 2022-10-17, 12:44 AM
Last Post: sgilani
  is there a service?method which returns listings for multiple channels? reven 16 6,794 2022-04-11, 04:30 PM
Last Post: mandai
  New Systems Plugin kirschey 10 3,296 2020-11-14, 08:01 PM
Last Post: sub
  VIdeo playback from plugin mvallevand 5 3,422 2015-08-06, 10:43 PM
Last Post: sub
  Show artwork method psycik 31 11,659 2015-07-14, 07:06 AM
Last Post: aloxinh
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 2,861 2014-11-14, 02:05 AM
Last Post: Benoire
  couple of issues with recording.recurring.save method reven 10 4,632 2014-01-03, 11:11 PM
Last Post: reven
  Advice on which streaming method to use fred250 17 6,160 2013-09-14, 11:14 AM
Last Post: fred250
  getting recurring recordings from service?method API? reven 2 1,920 2013-08-03, 10:50 PM
Last Post: reven
  API docs to help with plugin development? McBainUK 3 2,738 2013-06-08, 06:14 PM
Last Post: sub

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

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

Linear Mode
Threaded Mode