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 see no reason in Windows XP or 7, in my experience, on ancient Atom, Windows 10 worked faster than XP or 7...
    I see no reason in Windows XP or 7, in my experience, on ancient Atom, Windows 10 worked faster than XP or 7...
    Hi all, I'm new to MediaPortal and looking forward to using it. Just one catch and I apologize if it sounds silly - I want to run...
    Replies
    3
    Views
    1K
    MP1 MP2 Kodi Plugin DE
    Some MP2 installers contain three TV Servers: TVE3 TVE3.5 TvMosaic If the installer that you used offers you the choice of these three TV Servers, select TVE3. If you selected TVE3.5, run the installer again and select TVE3. The Kodi plugin is described as being intended for MP 2.5 and TVE3, so it should work. Unfortunately I do...
    Some MP2 installers contain three TV Servers: TVE3 TVE3.5 TvMosaic If the installer that you used offers you the choice of these...
    Hi, I have read some thread discussions but I still have not understood what is happening. I have MediaPortal 2.5. To use it...
    Replies
    2
    Views
    669
    Sorry, it's my fault -- I did not notice that you are using MP2. :( MP1 has a separate configuration utility, similar to "TV Server Config". I have tried MP2 only a couple of times, and have never used it seriously. I don't know what MP2 supports with regard to adjusting audio delay, but I do know that all of the adjustments of...
    Sorry, it's my fault -- I did not notice that you are using MP2. :( MP1 has a separate configuration utility, similar to "TV...
    Hi. I recently upgraded my home cinema AVR which also meant changed from sending audio from my HTPC as 5.1 using optical to 7.1...
    Replies
    5
    Views
    1K
    I do not know why this xml was in my theme folders, it must have sneaked in some time ago (years?). I simply removed the file. The Latest Media Handler plugin seems to be working as expected. I've had no lock-ups.
    I do not know why this xml was in my theme folders, it must have sneaked in some time ago (years?). I simply removed the file. The...
    Before you create this bug report: Make sure that your system (windows, codecs and drivers) is up to date, matching the...
    Replies
    13
    Views
    2K
    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
    2K
    Top Bottom