4

이것은 이상한 것입니다.Windows Phone 8 백그라운드 에이전트는 디버그 빌드를 사용할 때만 실행됩니다 (릴리스 빌드에서는 실행 중이 아닌 것 같습니다)

내 Windows Phone 8 앱의 백그라운드 에이전트가 디버그 빌드를 실행할 때 하루 종일 완전히 업데이트되는 것 같습니다. 그러나 릴리스 빌드로 변경하면 전혀 실행되지 않거나 드물게 실행되지 않습니다. 날씨 앱용입니다. 라이브 타일의 콘텐츠는 매 시간마다 변경되어야합니다. 나는 때때로 그것을 매 시간마다 업데이트하는 것을 보았지만 몇 시간 동안 멈추었다가 갑자기 다시 시작하는 것을 보았습니다. 어느 시점에서든 앱의 백그라운드 에이전트는 OS에 의해 차단 되어도 나에게 백그라운드 에이전트에 아무런 문제가 없거나 전혀 실행되지 않는다고 제안합니다.

현재 Windows Phone 8.1을 실행하는 Lumia 1020에서 응용 프로그램의 디버그 및 릴리스 빌드가 있습니다. 코드와 동일합니다. 디버그 빌드는 30 분마다 업데이트됩니다 (라이브 타일의 타임 스탬프 원인은 알고 있습니다). 릴리스 빌드는 90 분 전에 생성되었으므로 업데이트되지 않았습니다 (그러나 백그라운드 에이전트는 여전히 '허용됨'으로 나열되어 있습니다). 배터리 세이버 앱에서 실행).

private void AddAgent(string periodicTaskName) 
    { 
     periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask; 
     if (periodicTask != null) 
     { 
      RemoveAgent(periodicTaskName); 
     } 

     periodicTask = new PeriodicTask(periodicTaskName); 
     periodicTask.Description = "LiveTileHelperUpdateTask"; 

     try 
     { 
      ScheduledActionService.Add(periodicTask); 

      // If debugging is enabled, use LaunchForTest to launch the agent in 5 seconds. 
      //#if(DEBUG_AGENT) 
       ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(1)); 
      //#endif 
     } 
     catch (InvalidOperationException) 
     { 

     } 
     catch (SchedulerServiceException) 
     { 

     } 
    } 

그리고 여기에 예약 에이전트 코드입니다 : 여기

는 에이전트를 생성하는 방법의 유사한 경험이 원인이 될 수있는 어떤 아이디어를 가지고 또는 가지고

public class ScheduledAgent : ScheduledTaskAgent 
{ 
    /// <remarks> 
    /// ScheduledAgent constructor, initializes the UnhandledException handler 
    /// </remarks> 
    static ScheduledAgent() 
    { 
     // Subscribe to the managed exception handler 
     Deployment.Current.Dispatcher.BeginInvoke(delegate 
     { 
      Application.Current.UnhandledException += UnhandledException; 
     }); 
    } 

    /// Code to execute on Unhandled Exceptions 
    private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) 
    { 
     if (Debugger.IsAttached) 
     { 
      // An unhandled exception has occurred; break into the debugger 
      Debugger.Break(); 
     } 
    } 

    /// <summary> 
    /// Agent that runs a scheduled task 
    /// </summary> 
    /// <param name="task"> 
    /// The invoked task 
    /// </param> 
    /// <remarks> 
    /// This method is called when a periodic or resource intensive task is invoked 
    /// </remarks> 
    protected async override void OnInvoke(ScheduledTask task) 
    { 
     // If the app has not been purchased and trial has expired, 
     // don't do anything here. 
     if((bool) IsolatedStorageSettings.ApplicationSettings["TrialExpired"] == true) 
      return; 

     // Setup view model to get data from.  
     LiveTileViewModel viewModel = new LiveTileViewModel(); 
     await viewModel.getWeatherForTileLocation(); 

     // Use a dispatcher because we are NOT on the UI thread! 
     Deployment.Current.Dispatcher.BeginInvoke(() => 
     { 
      try 
      {     
       RadFlipTileData extendedData = new RadFlipTileData(); 
       extendedData.IsTransparencySupported = true; 

       // Determine which sized tile will be the live tile. 
       // Only create a live tile for it due to memory constraints. 
       string liveTileSize = IsolatedStorageSettings.ApplicationSettings["LiveTileSize"].ToString(); 
       switch (liveTileSize) 
       { 
        case "SMALL TILE": 
         extendedData.SmallVisualElement = new LiveTileSmall() 
         { 
          Icon = viewModel.Location.Hourly.Data[0].Icon, 
          Temperature = viewModel.Location.Hourly.Data[0].Temperature 
         }; 
        break; 
        case "REGULAR TILE": 
         // Code here similar to small tile's 
        break; 
        default: 
         // Code here similar to small tile's 
        break; 
       } 

       FreeMemory(); 

       foreach (ShellTile tile in ShellTile.ActiveTiles) 
       { 
        LiveTileHelper.UpdateTile(tile, extendedData); 
        break; 
       } 

       NotifyComplete(); 
      } 
      catch (Exception e) 
      { 
      } 
     }); 
    } 
} 
} 

누구나 어디 배경 에이전트는 디버그 빌드에서만 작동합니까?

감사합니다.

+0

에이전트의 파일에 오류를 기록하십시오. try catch에 모든 코드를 래핑하고 catch에 로그인하십시오. 메모리가 부족한만큼 작게 유지하십시오. 모든 작업을 기록하고 로컬 텍스트 파일에 의존하는 대신 데이터를 보낼 수있는 서비스를 설정하는 것이 좋습니다. 빠른 디버깅을 위해 Google 웹 로그 분석을 사용할 수 있습니다. –

+0

이 문제를 해결하는 데 협조 해주십시오. 디버그를 해제 모드로 설정하면 백그라운드 작업이 실행되지 않습니다. 그것은 디버그 모드에서 잘 작동했다. 그리고 Windows Phone 8.1 프로젝트에서는 디버그 모드로 빌드 된 .xap 파일을 업로드 할 수 없습니다. 릴리스 모드로 설정해야하지만 릴리스 모드로 설정하면 백그라운드 작업이 작동하지 않습니다. –

+0

나는 동일한 문제가있다. –

답변

0

디버그 빌드를 제거하고 백그라운드 작업 실행을 확인하기 위해 릴리스를 설치하려고 했습니까?

또한 릴리스 빌드에 대한 ScheduledActionService.LaunchForTest 메서드 호출을 제거하려고 시도 할 때 문서의주의 섹션을 참조하십시오. 현재 코드에서는 매 1 초마다 백그라운드 실행 테스트 실행을 트리거하도록 지정했습니다. 이 제한 시간이 60 초 미만이면 작업이 실행되지 않을 수도있는 경우가 있습니다.