2012-12-27 2 views
1

그래서 저는 Windows 스토어 응용 프로그램에서 백그라운드 작업을하는 데 문제가있는 것 같습니다. 필자는 튜토리얼 백서를 따라 갔고 Microsoft의 샘플 코드와 모든 코드 반복 작업이 실패한 것처럼 보였지만 사라졌습니다. Visual Studio는 백그라운드 작업이 실행되지 않는 오류를주지 않으며, 인터넷 연결이있을 때마다 70 분마다 실행하는 것이 목적입니다.Windows 8 백그라운드 작업

코드의 범위는 아래에 자신의 프로젝트라는 작업에있어, 그리고 (안이 프로젝트하지만 솔루션의 주요 프로젝트에 대한) 제대로 백그라운드 작업이 가득 매니페스트이 클래스에서 찾을 수

class BackroundBuilder 
{ 
    public BackroundBuilder() 
    { 
    this.RegisterTimeTriggerBackgroundTask(); 
    } 

    //this is the code that registers my backround task to run a trigger 
    //was added for testing. 
    private bool RegisterTimeTriggerBackgroundTask() 
    { 
    BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); 
    builder.Name = "Background task test"; 
    builder.TaskEntryPoint = "PostPage.xmal"; 
    // Run every 70 minutes if the device has internet connectivity 
    IBackgroundTrigger trigger = new TimeTrigger(70, false); 
    builder.SetTrigger(trigger); 
    IBackgroundCondition condition = new 
     SystemCondition(SystemConditionType.InternetAvailable); 

    //this is the trigger it's set to fire when internet becomes available    
    IBackgroundTrigger Itrigger = new 
     SystemTrigger(SystemTriggerType.InternetAvailable,true); 
    builder.SetTrigger(Itrigger); 

    builder.AddCondition(condition); 
    IBackgroundTaskRegistration task = builder.Register(); 

    return true; 
    } 

    public async void Run(IBackgroundTaskInstance taskInstance) 
    { 
    BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();    

    //WindowsBlogReader.FeedDataSource updateAll = new WindowsBlogReader.FeedDataSource(); 
    //direct input for the test string is declared below but the updateAll declaration  
    // above is the one that will be used once the test works 
    WindowsBlogReader.LiveTileTimeUpdate updateAll = new WindowsBlogReader.LiveTileTimeUpdae(); 

    //this is the test to see if the background task will fire 
    //await was in front of the below statement but im injecting that String into a method 
    //that is not setup for async the method being used once this works is an async 
    updateAll.update("Background task fired"); 
    //this update method adds a String too the list of Sting that's the live tile cycles though 
    _deferral.Complete(); 
    }  
} 

이 어떤 도움을 주시면 감사하겠습니다

<Extension Category="windows.backgroundTasks" EntryPoint="Tasks.BackroundBuilder"> 
    <BackgroundTasks> 
    <Task Type="systemEvent" /> 
    <Task Type="timer" /> 
    </BackgroundTasks> 
</Extension> 

매니페스트 XML 코드를입니다. 이 코드가 충분한 정보가 아니라면 더 많은 정보를 얻을 수 있습니다. 앱이 실행 중일 때 모든 기능이 작동하므로 앱의 다른 부분에는 알려진 (알려진) 문제가 없습니다.

+0

백그라운드 작업 선언과 관련된 매니페스트의 XML 코드를 추가했습니다. –

답변

0

TaskEntryPointIBackgroundTask을 구현하는 클래스 (네임 스페이스 포함)의 이름이어야합니다. 예 : "BackgroundTasks.MyBackgroundTask"
또한 매니페스트 파일에 추가해야합니다. Package.appxmanifest를 열고 신고 탭으로 이동하여 백그라운드 작업 선언을 추가하고 동일한 이름 (예 : 'BackgroundTasks.MyBackgroundTask')으로 '입력 지점'입력란을 채 웁니다.
또한 작업은 별도의 Windows 런타임 구성 요소 프로젝트에 있어야하며 해당 프로젝트의 모든 클래스는 publicsealed이어야합니다.

Here은 빠른 자습서입니다.
광범위한 것은 here입니다.

0

BackroundBuilder 클래스에 IBackgroundTask interface 클래스를 구현해야합니다.

+0

나는 이것을 한 번하고 나는 그것이 내 영혼을 게시 할 때 아프다는 것을 확신한다. –

0

오타가 되니 : builder.TaskEntryPoint = "PostPage.xmal";해야할까요 : builder.TaskEntryPoint = "PostPage.xaml";? SLaks의 대답으로 문제를 해결하지 못하는 것 같아요.

의견으로 입력하겠습니다 만 담당자를 지정할 권한이 없습니다.

+0

아니, 그래도 질문을 읽을 시간을내어 주셔서 감사하지 않아. –

관련 문제