Namespaces
Variants
Actions
Revision as of 07:09, 21 January 2013 by vdharankar (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to create simple Background Agent in Windows Phone

Jump to: navigation, search

Delete instructional text in italic

This article explains how to ... Replace the abstract text with a short paragraph (or sentence) describing what the topic covers.

Enter article metadata as described below. Note that this template can be placed anywhere in the article. Do not remove parameters that you do not use

SignpostIcon Code 52.png
Article Metadata

Article
Created: (09 Jun 2013)
Last edited: vdharankar (21 Jan 2013)

Contents

Introduction

This article explains how to create a simple background agent in Windows Phone. There is a MSDN example on how to create a background agent but its not simple it has additional stuff in it, so if you are looking for just plain simple how to ? here it is.

Basic requirements

You need to create an app project , it can be anything from simple basic windows phone app to panorama or pivote based application. Then create your background agent project in the same solution and add its reference to the main app, with necessary code ( which is hardly few lines) you can have your background agent running. You can test agents in simulator as well.

How to....

  • Create a simple windows phone application project as follows and give some suitable name to it.


Screenshot (4).png

  • Create a scheduled task agent project in Visual Studio, this should be added to the same solution , an easy way to do is, goto solution explorer of main application right click on solution and select add, select add project and automatically the project created will get added to the existing solution. Assign some suitable name to the project.


Screenshot (5).png


  • Next step is to add a reference to the main application it can be done by going to Solution Explorer, right click references under main project and select Add Reference option.


Screenshot (6).png


  • Next select Solutions section on the Add Reference dialog and you should be able to see the name of your scheduled task agent project name there select it and its done.

Screenshot (7).png


  • Next open ScheduledAgent.cs file from your background agent project and add following lines of code in OnInvoke method

[code lang=csharp]

 string toastMessage = "Periodic task running.";
           ShellToast toast = new ShellToast();
           toast.Title = "Background Agent Sample";
           toast.Content = toastMessage;
           toast.Show();
  1. if DEBUG_AGENT
 ScheduledActionService.LaunchForTest(task.Name,TimeSpan.FromSeconds(60));
  1. endif
           NotifyComplete();

[/code]

Summary

Remove Category:Draft when the page is complete or near complete


The "platform categories" will be displayed here in preview only - Copy paste relevant categories into text here


Add categories below using category selector.

980 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved