Latest Media Handler v2.4.X.000 (2 Viewers)

azzuro

Test Group
  • Team MediaPortal
  • May 10, 2007
    9,984
    5,663
    France - IDF
    Home Country
    France France
    Wrong thread is back
    Code:
    [2015-11-26 18:53:37,501] [Error  ] [RefreshWorker-LatestMediaHandler.LatestMyVideosHandler] [ERROR] - LoadSkin: Running on wrong thread - StackTrace: '   Ã  System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
       Ã  System.Environment.get_StackTrace()
       Ã  MediaPortal.GUI.Library.GUIWindow.LoadSkin()
       Ã  MediaPortal.GUI.Library.GUIWindow.AllocResources()
       Ã  MediaPortal.GUI.Library.GUIWindow.DoRestoreSkin()
       Ã  MediaPortal.GUI.Library.GUIWindowManager.GetWindow(Int32 dwID, Boolean tryRestoreSkin)
       Ã  LatestMediaHandler.Utils.GetLatestsFacade(Int32 ControlID)
       Ã  LatestMediaHandler.LatestMyVideosHandler.InitFacade(Boolean OnActivate)
       Ã  LatestMediaHandler.LatestMyVideosHandler.MyVideosUpdateLatest()
       Ã  LatestMediaHandler.RefreshWorker.OnDoWork(DoWorkEventArgs e)
       Ã  System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
       Ã  System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
       Ã  System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
       Ã  System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
       Ã  System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       Ã  System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       Ã  System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       Ã  System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       Ã  System.Threading.ThreadPoolWorkQueue.Dispatch()
       Ã  System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()'
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    GetLatestsFacade
    Code:
        internal static GUIFacadeControl GetLatestsFacade(int ControlID)
        {
          try
          {
            if (GUIWindowManager.ActiveWindow > (int)GUIWindow.Window.WINDOW_INVALID)
            {
              GUIWindow gw = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow);
              GUIControl gc = gw.GetControl(ControlID);
              return gc as GUIFacadeControl;
            }
          }
          catch (Exception ex)
          {
            logger.Debug("GetLatestsFacade: " + GUIWindowManager.ActiveWindow + " - " + ControlID);
            logger.Error("GetLatestsFacade: " + ex);
          }
          return null;
        }
    @Sebastiii It seems to me here that it is necessary to solve and everything will be fine in all plug-ins ...
    MediaPortal.GUI.Library.GUIWindow.LoadSkin()
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    @azzuro
    10x for info:
    Code:
    26-Nov-2015 18:53:35 Debug [               Utils]: Latest: [x] Pictures, [x] Music, [x][x] MyVideo, [ ][x] TVSeries, [ ][x] TV Recordings, [ ][x] MovingPictures, [ ][x] MyFilms, [ ] MvCentral
    26-Nov-2015 18:53:35 Debug [               Utils]: Plugin enabled: [x] Music, [x] Pictures, [x] MyVideo, [ ] TVSeries, [ ] MovingPictures, [ ] MyFilms, [ ] MvCentral
     

    azzuro

    Test Group
  • Team MediaPortal
  • May 10, 2007
    9,984
    5,663
    France - IDF
    Home Country
    France France
    @azzuro
    10x for info:
    Code:
    26-Nov-2015 18:53:35 Debug [               Utils]: Latest: [x] Pictures, [x] Music, [x][x] MyVideo, [ ][x] TVSeries, [ ][x] TV Recordings, [ ][x] MovingPictures, [ ][x] MyFilms, [ ] MvCentral
    26-Nov-2015 18:53:35 Debug [               Utils]: Plugin enabled: [x] Music, [x] Pictures, [x] MyVideo, [ ] TVSeries, [ ] MovingPictures, [ ] MyFilms, [ ] MvCentral
    Sorry. Dont understand the "10x "
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    Wrong thread is back

    In LatestMediaHandler.RefreshWorker.OnDoWork() the call to LatestMediaHandler.LatestMyVideosHandler.MyVideosUpdateLatest() should switch to the main thread.
    you can use :

    Code:
    if (System.Windows.Forms.Form.ActiveForm.InvokeRequired)
    {
        System.Windows.Forms.Form.ActiveForm.Invoke(MyVideosUpdateLatest);
    }
    else
    {
        MyVideosUpdateLatest();
    }
    to do the switch
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    In LatestMediaHandler.RefreshWorker.OnDoWork() the call to LatestMediaHandler.LatestMyVideosHandler.MyVideosUpdateLatest() should switch to the main thread.
    you can use
    The update will block the main thread?
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    Yes it will. You cannot update GUI controls in a background thread. If you do, you will get a "Collection changed during enumeration" exception (in the best case) or the "LoadSkin: Running on wrong thread" (worst case). If you are careful you can switch to the main thread only for certain operations that may cause issues and do the rest in the background. However this might not be safe - something that works now may break in the future because of an unexpected change in one of the methods called in the background thread.

    Since in MP1 there is no discrete well defined API and hence no documentation about threading (= guaranteed thread-safety) there is no way to know but to assume pretty much nothing is thread safe.

    Do all your data manipulation in the background then switch to the main thread to talk to GUILib

    PS: MP also has a way to handle executing code on the main thread (events) but it is very cumbersome IMHO. It does however guarantee that the code will be run in a specific sequence in the message loop (before Process() IIRC).
     

    Sebastiii

    Development Group
  • Team MediaPortal
  • November 12, 2007
    16,583
    10,403
    France
    Home Country
    France France
    GetLatestsFacade
    Code:
        internal static GUIFacadeControl GetLatestsFacade(int ControlID)
        {
          try
          {
            if (GUIWindowManager.ActiveWindow > (int)GUIWindow.Window.WINDOW_INVALID)
            {
              GUIWindow gw = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow);
              GUIControl gc = gw.GetControl(ControlID);
              return gc as GUIFacadeControl;
            }
          }
          catch (Exception ex)
          {
            logger.Debug("GetLatestsFacade: " + GUIWindowManager.ActiveWindow + " - " + ControlID);
            logger.Error("GetLatestsFacade: " + ex);
          }
          return null;
        }
    @Sebastiii It seems to me here that it is necessary to solve and everything will be fine in all plug-ins ...
    MediaPortal.GUI.Library.GUIWindow.LoadSkin()

    Already tried with no luck :(
     

    Users who are viewing this thread

    Top Bottom