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


    Write your reply...

    Similar threads

    I'm trying to get a KodiClient running with MP-Server 1.36. I have access to the server ((Program information is loading), but I can't access c:\ProrammData\Mediaportal\...\timeshift. What permissions do I still need to set?
    I'm trying to get a KodiClient running with MP-Server 1.36. I have access to the server ((Program information is loading), but I...
    I'm trying to get a KodiClient running with MP-Server 1.36. I have access to the server ((Program information is loading), but I...
    Replies
    0
    Views
    669
    For music you may use --> https://www.team-mediaportal.de/erweiterungen/musik/global-search With GlobalSearch you can search for any entry in your music database: Artist, Album, Title, Lyrics... I'm afraid there is no such plugin :unsure:
    For music you may use --> https://www.team-mediaportal.de/erweiterungen/musik/global-search With GlobalSearch you can search for...
    HI, I'm new to MediaPortal and have a question about searching for data. I have an extensive collection of music, films, and TV...
    Replies
    1
    Views
    991
    It is present, but not with that name. It is called Scheduler, viz: Interesting. I had never noticed that when the "command" is "ACTION", the "cmdproperty" is the actual window id, but it makes sense that it is. Try this for yourself. First backup your working profile for the remote, then in the "Mapping" panel make a change to...
    It is present, but not with that name. It is called Scheduler, viz: Interesting. I had never noticed that when the "command" is...
    I would like to be able to go directly to the Scheduled recordings window without having to first go to the home menu. I saw this...
    Replies
    1
    Views
    220
    The reason I was thinking I needed more RAM is that TV now seems to be HiDef and so the files have grown. I edit the files before storing them, to reduce some size. It is finding that slower, I think. Or it could just be because I'm expecting more? The Baseboard manufacturer says ASUSTech Computer Inc; Baseboard product P7P55D-E...
    The reason I was thinking I needed more RAM is that TV now seems to be HiDef and so the files have grown. I edit the files before...
    I'm not sure where to post this query - I've been told, during a conversation about costs of upgrading, that W11 may not support my...
    Replies
    4
    Views
    395
    • Sticky
    MP 1.37 Final (Willow) Bugfix II released, download links updated...
    MP 1.37 Final (Willow) Bugfix II released, download links updated...
    We have just released MediaPortal 1.37 - Willow x86 and x64 version. Highlights of this release Bugfixes: [MP1-5232] - GPU...
    Replies
    4
    Views
    713
    Top Bottom