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

    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
    404
    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
    458
    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
    3K
    I did a check of MP 1.36 x64 on Win11 and I can confirm, that the TV server correctly detects running MediaPortal.exe process.
    I did a check of MP 1.36 x64 on Win11 and I can confirm, that the TV server correctly detects running MediaPortal.exe process.
    Hi, I am using MP in a client-only setup including DVB-S card for over 10 years now. And regularily scheduling records waking up...
    Replies
    9
    Views
    720
    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
    Top Bottom