how to detect that mediaportal is closed in a plugin (1 Viewer)

packstlauren

MP Donator
  • Premium Supporter
  • November 26, 2006
    87
    50
    Home Country
    France France
    Hi,

    I'm writing a plugin and i need to manage my own thread. But when i closed MediaPortal my thread continue to run. I want to stop it when mediaportal is closing.


    Thanks,

    Pack
     

    patrick

    Portal Pro
    April 20, 2005
    608
    45
    Southeast
    Home Country
    United States of America United States of America
    Hi,

    I'm writing a plugin and i need to manage my own thread. But when i closed MediaPortal my thread continue to run. I want to stop it when mediaportal is closing.


    Thanks,

    Pack

    I am guessing you are writing a process plugin.
    IIRC, it is part of the IPlugin interface

    Code:
    public void Stop()
    {
    }


    HTH,
    patrick
     

    packstlauren

    MP Donator
  • Premium Supporter
  • November 26, 2006
    87
    50
    Home Country
    France France
    Thanks for your help !

    As I'm writing a GuiWindow plugin, the IPplugin interface can't solve my problem. But i find a solution with a System.Windows.Forms.Timer() like in the alarm plugin.

    I tried to search documentation about MediaPortal source code. But I haven't found anything...Does it exist a documentation ?

    Pack
     

    nefreyu

    Portal Member
    February 4, 2007
    9
    1
    Home Country
    Netherlands Netherlands
    As any plugin is a class that is instantiated by MP and will be destroyed by MP on close, you should be able to override the destroy method ( not sure how it is called in C#) and do your cleanup in their I suppose.
     

    reagan+carter

    Portal Pro
    September 6, 2006
    221
    2
    Nantes, FR
    it is not really advisable to put code intot the destructor if you still need to communicate with MediaPortal
    Code:
    ~name_of_your_class()
    you'd better use the DeInit() procedure of the main plugin form
    Code:
    procedure public override void DeInit()
    which is safe.
     

    packstlauren

    MP Donator
  • Premium Supporter
  • November 26, 2006
    87
    50
    Home Country
    France France
    Perhaps i think wrong, but i think that the deinit method is call when you quit the window page of the plugin. So if you want to run a process even if the user is not on the plugin page the deinit method cannot be used to kill the process.
     

    reagan+carter

    Portal Pro
    September 6, 2006
    221
    2
    Nantes, FR
    hello,
    the main plugin form is loaded at startup and only released when mediaportal shuts down. So DeInit() should work (the comments in the code were not clear on the subject). However you're right regarding the GUI_MSG_WINDOW_DEINIT message in the OnMessage() loop, this one is sent each time the form is hidden. My mistake.

    I've edited the above post.
     

    reagan+carter

    Portal Pro
    September 6, 2006
    221
    2
    Nantes, FR
    1) Mediaportal main loop is required to terminate [app.OnExit(), MediaPortal.cs, line 355]
    2) The Window Manager is asked to shut down any window it still handles [GUIWindowManager.Clear(), MediaPortal.cs, line 1032]
    3) Each window (including plugins, which are dynamically loaded at satrtup) cleans its own mess (_listWindows[x].DeInit(), GUIWindowManager.cs, line 432)

    I use DeInit() myself to properly terminate my own threads when MediaPortal stops.
     

    packstlauren

    MP Donator
  • Premium Supporter
  • November 26, 2006
    87
    50
    Home Country
    France France
    You're right !
    The Deinit method is called when MediaPortal is closing.

    Thanks for your help.


    Pack
     

    Users who are viewing this thread

    Similar threads

    The only changes I see are: Updated Marcel Groothuis version of the plugin to now support Media Portal 2.5 I can't say anything about the functionality of this plugin, I don't use TV Part, but if there are any changes that can be simply transferred, then I can try. But I can't give any guarantees.
    The only changes I see are: Updated Marcel Groothuis version of the plugin to now support Media Portal 2.5 I can't say anything...
    I am a long-time user of MediaPortal to watch TV. I use the Media Portal TV Server as a backend, and Kodi (previously known as...
    Replies
    15
    Views
    2K
    You can always use GitHub online But judging by the picture, you are doing well. Direct Push to Master is prohibited, create PR.
    You can always use GitHub online But judging by the picture, you are doing well. Direct Push to Master is prohibited, create PR.
    Hello, Because I was annoyed with closing MP, launch config, modify setting and start MP again, I decided to give MP the ability...
    Replies
    5
    Views
    3K
    Hi, yes, you are right. The official x64 1.32 is buggy. You can try a new installers from this post if you like.
    Hi, yes, you are right. The official x64 1.32 is buggy. You can try a new installers from this post if you like.
    hi, I'm setting up a new computer and have installed MP 1.3.2 after a few goes and getting all the prereqs installed, I was...
    Replies
    3
    Views
    1K
    I've updated dlls in first post. Fixes: Summary / Overview was always empty Collections were not filtered to official ones Studios were not populated Fallback to english tagline didn't work Score / Popularity now empty instead of dummy rating and unknown popularity numbers Also I've tried to compile plugin against MP 1.34 x64 and...
    I've updated dlls in first post. Fixes: Summary / Overview was always empty Collections were not filtered to official ones Studios...
    Hi! TheTVDB.com has movies in their API now. API itself looks ok now so I decided to add TVDB to Moving Pictures. Check it if you...
    Replies
    2
    Views
    808
    MP1 MP2 1.34 STB blasting for IPTV DE
    I'm downsizing my big honkin' HTPC case to a mini PC, which means the tried and true Hauppauge Colossus card that bridges the set top box into Mediaportal needs replaced with a different solution. I currently have HDMI from the STB to the colossus. Mediaportal is controlling the STB through a USBUIRT blaster and the blaster is...
    I'm downsizing my big honkin' HTPC case to a mini PC, which means the tried and true Hauppauge Colossus card that bridges the set...
    I'm downsizing my big honkin' HTPC case to a mini PC, which means the tried and true Hauppauge Colossus card that bridges the set...
    Replies
    0
    Views
    651
    Top Bottom