Windows Phone “Tango”

An early update on Windows Phone 7.8 release–coming in Q1-2013

November 29, 2012 .NET, All, Community, KnowledgeBase, Microsoft, Mobile-Development, MSDN, Updates, Windows, Windows Phone, Windows Phone "Mango", Windows Phone "Tango", Windows Phone 7, Windows Phone 7.0, Windows Phone 7.5, Windows Phone 7.8, Windows Phone Development, Windows Phone SDK No comments

Yesterday Microsoft Windows Phone Team announced the availability of Windows Phone 7.8 to existing Windows Phone 7.x family of devices by early 2013.

Some of the interesting features announced are:

  • New Customizable start screen with resizable Live Tiles.
  • It doubles the number of theme and accent colors—to 20—so you can make your phone even more personal.
  • There are also new lock screen features: the option to automatically display the Bing Picture of the Day plus the ‘A1B2C3’ PIN/password challenge to prevent accidental device wipes on phones connected to Exchange accounts.

You want to read more about this announcement visit: Windows Phone Team blog

Windows Phone 7.8 Feature set Leaked

August 15, 2012 .NET, All, Featured, Microsoft, Windows, Windows Phone, Windows Phone "Tango", Windows Phone 7, Windows Phone 7.5, Windows Phone 7.8, Windows Phone 8, Windows Phone Development, Windows Phone SDK No comments

Recently leaked Windows Phone 7.8 feature list indicates some of the interesting features you can expect as part of Windows.

Windows Phone 7.8 is an incremental update to existing Windows Phone 7.x platform, as upcoming Windows Phone 8 will not work on existing windows phone 7.x devices, because hardware signature and kernel might change as part of Windows Phone 8 improved features.

So Microsoft is planning to release an incremental update that includes some of the features of Windows Phone 7.x to satisfy the existing Windows Phone users, this incremental update is officially announced as Windows Phone 7.8.

 

Some of the features of Windows Phone 7.8 includes:

  1. Windows Phone 7.8 will sport the new home screen tiles, with variable sizes allowing more to fit on the display
  2. Improved camera application with Smart Group Shot, action, panorama and self-timer options.
  3. Wi-Fi tethering to Windows Phone 7.8
  4. Ability to flip the phone over to silence an incoming call, message tone or alarm.

Some  interesting features of Windows Phone 8 we might miss as part of Windows Phone 7.8 release.

Features not coming to Windows Phone 7.8 include:

  • Over-the-air updates
  • Support for screen resolutions higher than WVGA
  • Internet Explorer 10
  • Multi-core processor support
  • Wallet Hub
  • NFC
  • Real multitasking
  • MicroSD card support
  • Device Management
  • Company Hub
  • Secure Boot and Encryption
  • IE 10

Another interesting news is that, the Windows Phone 8 release date is set for October 27, the same as Microsoft’s main Windows 8 operating system,

You can read through the full original article at Tech Radar and WPFanboy’s blog

Windows Phone Development–Background Agents in Windows Phone

April 26, 2012 .NET, All, Codes, KnowledgeBase, Microsoft, Microsoft SDKs, Mobile-Development, Silverlight, VisualStudio, VS2010, Windows, Windows Phone, Windows Phone "Mango", Windows Phone "Tango", Windows Phone 7, Windows Phone 7.0, Windows Phone 7.5, Windows Phone Development, Windows Phone SDK No comments

Windows Phone came through long way after it’s initial release on Oct 21st 2010.  Windows Phone 7.5 update release called as “MANGO” brought lots of improvements including Multi tasking capabilities etc. With the introduction of multi-tasking ( it is not true multi tasking, but an efficient application switching which ensures that only one application will reside in memory and remaining running applications will be in deactivated stage. Since the application is not killed, it can be launched faster – that gives the capability similar to true multi tasking).

What is Background Agents?

Background agents feature allows you to run certain code in a background thread and scheduled tasks  are that runs periodically.

Scheduled Tasks and background agents allow an application to execute code in the background, even when the application is not running in the foreground. The different types of Scheduled Tasks are designed for different types of background processing scenarios and therefore have different behaviors and constraints.

Note: that Background agents are not supported in 256MB devices. Only initial 512MB devices with Windows Phone “MANGO” would be able to run background agents

 

There are types of scheduled tasks or Background Agents and they are:

1. Periodic Task Agents- Periodic task agents will run for a short period of time and does a certain predefined operations defined by you. It also have the capability to run based on certain time interval.

A typical example would be checking whether device is having network connectivity periodically or checking any mails available with mail server etc.

2. Resource Intensive Task Agents- Resource Intensive tasks agents will run for a long period if all your network connectivity(if you need some network processing while doing the task) and power and resource usage etc.

A Typical example of scenario would be your phone receiving some application data updates and additional feature set update etc.

 

Using Background Agents:

1. To start with Scheduled tasks agents are part of Microsoft.Phone.Scheduler namespace

2. Create a new Windows Phone Scheduled Task project in your Windows Phone solution

image

3. Click on “OK” and Now I created a Windows Phone Scheduled Task project called  “ScheduledTaskAgent1

and this is how the initial code generated by Visual Studio will appear

using System.Windows;
using Microsoft.Phone.Scheduler;

namespace ScheduledTaskAgent1
{
    public class ScheduledAgent : ScheduledTaskAgent
    {
        private static volatile bool _classInitialized;

        /// <remarks>
        /// ScheduledAgent constructor, initializes the UnhandledException handler
        /// </remarks>
        public ScheduledAgent()
        {
            if (!_classInitialized)
            {
                _classInitialized = true;
                // Subscribe to the managed exception handler
                Deployment.Current.Dispatcher.BeginInvoke(delegate
                {
                    Application.Current.UnhandledException += ScheduledAgent_UnhandledException;
                });
            }
        }

        /// Code to execute on Unhandled Exceptions
        private void ScheduledAgent_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // An unhandled exception has occurred; break into the debugger
                System.Diagnostics.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 override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            NotifyComplete();
        }
    }
}

Now you can see there is an OnInvoke(ScheduledTask task) method, inside that method we will define our Periodic or Resource Intensive tasks implementation.

 

4. Now it is the time for us to do our implementation.  (This sample I have taken from MSDN Reference on How to: Implement Background Agents for Windows Phone)

         a.) Scheduled Task Code Implementation (this code will send toast messages, so that you can see that when your application is running in background. )

 /// <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 override void OnInvoke(ScheduledTask task)
        {

              //TODO: Add code to perform your task in background
              string toastMessage = "";

              // If your application uses both PeriodicTask and ResourceIntensiveTask
              // you can branch your application code here. Otherwise, you don't need to.
              if (task is PeriodicTask)
              {
                // Execute periodic task actions here.
                toastMessage = "Periodic task are running.";
              }
              else
              {
                // Execute resource-intensive task actions here.
                toastMessage = "Resource-intensive task are running.";
              }

              // Launch a toast to show that the agent is running.
              // The toast will not be shown if the foreground application is running.
              ShellToast toast = new ShellToast();
              toast.Title = "Background Agent Sample";
              toast.Content = toastMessage;
              toast.Show();

              // If debugging is enabled, launch the agent again in one minute.
            #if DEBUG_AGENT
              ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));
            #endif

              // Call NotifyComplete to let the system know the agent is done working.


            NotifyComplete();
        }

     

     b.) MainPage.xaml  markup

<span style="color: blue">&lt;</span><span style="color: #a31515">phone</span><span style="color: blue">:</span><span style="color: #a31515">PhoneApplicationPage 
    </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Class</span><span style="color: blue">=&quot;PhoneApp1.MainPage&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">:</span><span style="color: red">x</span><span style="color: blue">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">:</span><span style="color: red">phone</span><span style="color: blue">=&quot;clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">:</span><span style="color: red">shell</span><span style="color: blue">=&quot;clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">:</span><span style="color: red">d</span><span style="color: blue">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
    </span><span style="color: red">xmlns</span><span style="color: blue">:</span><span style="color: red">mc</span><span style="color: blue">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
    </span><span style="color: red">mc</span><span style="color: blue">:</span><span style="color: red">Ignorable</span><span style="color: blue">=&quot;d&quot; </span><span style="color: red">d</span><span style="color: blue">:</span><span style="color: red">DesignWidth</span><span style="color: blue">=&quot;480&quot; </span><span style="color: red">d</span><span style="color: blue">:</span><span style="color: red">DesignHeight</span><span style="color: blue">=&quot;768&quot;
    </span><span style="color: red">FontFamily</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneFontFamilyNormal</span><span style="color: blue">}&quot;
    </span><span style="color: red">FontSize</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneFontSizeNormal</span><span style="color: blue">}&quot;
    </span><span style="color: red">Foreground</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneForegroundBrush</span><span style="color: blue">}&quot;
    </span><span style="color: red">SupportedOrientations</span><span style="color: blue">=&quot;Portrait&quot; </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Portrait&quot;
    </span><span style="color: red">shell</span><span style="color: blue">:</span><span style="color: red">SystemTray.IsVisible</span><span style="color: blue">=&quot;True&quot;&gt;

    </span><span style="color: green">&lt;!--LayoutRoot is the root grid where all page content is placed--&gt;
    </span><span style="color: blue">&lt;</span><span style="color: #a31515">Grid </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;LayoutRoot&quot; </span><span style="color: red">Background</span><span style="color: blue">=&quot;Transparent&quot;&gt;
        &lt;</span><span style="color: #a31515">Grid.RowDefinitions</span><span style="color: blue">&gt;
            &lt;</span><span style="color: #a31515">RowDefinition </span><span style="color: red">Height</span><span style="color: blue">=&quot;Auto&quot;/&gt;
            &lt;</span><span style="color: #a31515">RowDefinition </span><span style="color: red">Height</span><span style="color: blue">=&quot;*&quot;/&gt;
        &lt;/</span><span style="color: #a31515">Grid.RowDefinitions</span><span style="color: blue">&gt;

        </span><span style="color: green">&lt;!--TitlePanel contains the name of the application and page title--&gt;
        </span><span style="color: blue">&lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;TitlePanel&quot; </span><span style="color: red">Grid.Row</span><span style="color: blue">=&quot;0&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;12,17,0,28&quot;&gt;
            &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;ApplicationTitle&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Craziness App&quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextNormalStyle</span><span style="color: blue">}&quot;/&gt;
            &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;PageTitle&quot; </span><span style="color: red">Text</span><span style="color: blue">=&quot;Tasks Sample&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;9,-7,0,0&quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextTitle1Style</span><span style="color: blue">}&quot;/&gt;
        &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;

        </span><span style="color: green">&lt;!--ContentPanel - place additional content here--&gt;
        </span><span style="color: blue">&lt;</span><span style="color: #a31515">Grid </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;ContentPanel&quot; </span><span style="color: red">Grid.Row</span><span style="color: blue">=&quot;1&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;12,0,12,0&quot;&gt;

            &lt;</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">StackPanel  </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Vertical&quot; </span><span style="color: red">Name</span><span style="color: blue">=&quot;PeriodicStackPanel&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;0,0,0,40&quot;&gt;
                    &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;Periodic Agent&quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextTitle2Style</span><span style="color: blue">}&quot;/&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;name: &quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Name</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;is enabled&quot; </span><span style="color: red">VerticalAlignment</span><span style="color: blue">=&quot;Center&quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">CheckBox </span><span style="color: red">Name</span><span style="color: blue">=&quot;PeriodicCheckBox&quot; </span><span style="color: red">IsChecked</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">IsEnabled</span><span style="color: blue">}&quot; </span><span style="color: red">Checked</span><span style="color: blue">=&quot;PeriodicCheckBox_Checked&quot; </span><span style="color: red">Unchecked</span><span style="color: blue">=&quot;PeriodicCheckBox_Unchecked&quot;/&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;is scheduled: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">IsScheduled</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;last scheduled time: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">LastScheduledTime</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;expiration time: &quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">ExpirationTime</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;last exit reason: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">LastExitReason</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                &lt;</span><span style="color: #a31515">StackPanel  </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Vertical&quot; </span><span style="color: red">Name</span><span style="color: blue">=&quot;ResourceIntensiveStackPanel&quot; </span><span style="color: red">Margin</span><span style="color: blue">=&quot;0,0,0,40&quot;&gt;
                    &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;Resource-intensive Agent&quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextTitle2Style</span><span style="color: blue">}&quot;/&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;name: &quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">Name</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;is enabled&quot; </span><span style="color: red">VerticalAlignment</span><span style="color: blue">=&quot;Center&quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">CheckBox </span><span style="color: red">Name</span><span style="color: blue">=&quot;ResourceIntensiveCheckBox&quot; </span><span style="color: red">IsChecked</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">IsEnabled</span><span style="color: blue">}&quot; </span><span style="color: red">Checked</span><span style="color: blue">=&quot;ResourceIntensiveCheckBox_Checked&quot; </span><span style="color: red">Unchecked</span><span style="color: blue">=&quot;ResourceIntensiveCheckBox_Unchecked&quot;/&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;is scheduled: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">IsScheduled</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;last scheduled time: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">LastScheduledTime</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;expiration time: &quot; </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">ExpirationTime</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                    &lt;</span><span style="color: #a31515">StackPanel </span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot;&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;last exit reason: &quot;  </span><span style="color: red">Style</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">StaticResource </span><span style="color: red">PhoneTextAccentStyle</span><span style="color: blue">}&quot;/&gt;
                        &lt;</span><span style="color: #a31515">TextBlock </span><span style="color: red">Text</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">Binding </span><span style="color: red">LastExitReason</span><span style="color: blue">}&quot; /&gt;
                    &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
                &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;
            &lt;/</span><span style="color: #a31515">StackPanel</span><span style="color: blue">&gt;


        &lt;/</span><span style="color: #a31515">Grid</span><span style="color: blue">&gt;
    &lt;/</span><span style="color: #a31515">Grid</span><span style="color: blue">&gt;
 
    </span><span style="color: green">&lt;!--Sample code showing usage of ApplicationBar--&gt;
    &lt;!--&lt;phone:PhoneApplicationPage.ApplicationBar&gt;
        &lt;shell:ApplicationBar IsVisible=&quot;True&quot; IsMenuEnabled=&quot;True&quot;&gt;
            &lt;shell:ApplicationBarIconButton IconUri=&quot;/Images/appbar_button1.png&quot; Text=&quot;Button 1&quot;/&gt;
            &lt;shell:ApplicationBarIconButton IconUri=&quot;/Images/appbar_button2.png&quot; Text=&quot;Button 2&quot;/&gt;
            &lt;shell:ApplicationBar.MenuItems&gt;
                &lt;shell:ApplicationBarMenuItem Text=&quot;MenuItem 1&quot;/&gt;
                &lt;shell:ApplicationBarMenuItem Text=&quot;MenuItem 2&quot;/&gt;
            &lt;/shell:ApplicationBar.MenuItems&gt;
        &lt;/shell:ApplicationBar&gt;
    &lt;/phone:PhoneApplicationPage.ApplicationBar&gt;--&gt;

</span><span style="color: blue">&lt;/</span><span style="color: #a31515">phone</span><span style="color: blue">:</span><span style="color: #a31515">PhoneApplicationPage</span><span style="color: blue">&gt;
</span>

and this is how my application screen would look like

image

   c. MainPage.xaml.cs implementation

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Scheduler;
using Microsoft.Phone.Tasks;

namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        PeriodicTask periodicTask;
        ResourceIntensiveTask resourceIntensiveTask;

        string periodicTaskName = "PeriodicAgent";
        string resourceIntensiveTaskName = "ResourceIntensiveAgent";
        public bool agentsAreEnabled = true;
        bool ignoreCheckBoxEvents = false;

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            
         
        }



        private void StartPeriodicAgent()
        {
            // Variable for tracking enabled status of background agents for this app.
            agentsAreEnabled = true;

            // Obtain a reference to the period task, if one exists
            periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;

            // If the task already exists and background agents are enabled for the
            // application, you must remove the task and then add it again to update 
            // the schedule
            if (periodicTask != null)
            {
                RemoveAgent(periodicTaskName);
            }

            periodicTask = new PeriodicTask(periodicTaskName);

            // The description is required for periodic agents. This is the string that the user
            // will see in the background services Settings page on the device.
            periodicTask.Description = "This demonstrates a periodic task.";

            // Place the call to Add in a try block in case the user has disabled agents.
            try
            {
                ScheduledActionService.Add(periodicTask);
                PeriodicStackPanel.DataContext = periodicTask;

                // If debugging is enabled, use LaunchForTest to launch the agent in 30 seconds.
             //   #if(DEBUG_AGENT)
                    ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(30));
                //#endif
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show("Background agents for this application have been disabled by the user.");
                    agentsAreEnabled = false;
                    PeriodicCheckBox.IsChecked = false;
                }

                if (exception.Message.Contains("BNS Error: The maximum number of ScheduledActions of this type have already been added."))
                {
                    // No user action required. The system prompts the user when the hard limit of periodic tasks has been reached.

                }
                PeriodicCheckBox.IsChecked = false;
            }
            catch (SchedulerServiceException)
            {
                // No user action required.
                PeriodicCheckBox.IsChecked = false;
            }
        }


        private void StartResourceIntensiveAgent()
        {
            // Variable for tracking enabled status of background agents for this app.
            agentsAreEnabled = true;

            resourceIntensiveTask = ScheduledActionService.Find(resourceIntensiveTaskName) as ResourceIntensiveTask;

            // If the task already exists and background agents are enabled for the
            // application, you must remove the task and then add it again to update 
            // the schedule.
            if (resourceIntensiveTask != null)
            {
                RemoveAgent(resourceIntensiveTaskName);
            }

            resourceIntensiveTask = new ResourceIntensiveTask(resourceIntensiveTaskName);

            // The description is required for periodic agents. This is the string that the user
            // will see in the background services Settings page on the device.
            resourceIntensiveTask.Description = "This demonstrates a resource-intensive task.";

            // Place the call to Add in a try block in case the user has disabled agents.
            try
            {
                ScheduledActionService.Add(resourceIntensiveTask);
                ResourceIntensiveStackPanel.DataContext = resourceIntensiveTask;

                // If debugging is enabled, use LaunchForTest to launch the agent in one minute.
                //#if(DEBUG_AGENT)
                    ScheduledActionService.LaunchForTest(resourceIntensiveTaskName, TimeSpan.FromSeconds(60));
                //#endif
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message.Contains("BNS Error: The action is disabled"))
                {
                    MessageBox.Show("Background agents for this application have been disabled by the user.");
                    agentsAreEnabled = false;

                }
                ResourceIntensiveCheckBox.IsChecked = false;
            }
            catch (SchedulerServiceException)
            {
                // No user action required.
                ResourceIntensiveCheckBox.IsChecked = false;
            }


        }

        private void PeriodicCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (ignoreCheckBoxEvents)
                return;
            StartPeriodicAgent();
        }
        private void PeriodicCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            if (ignoreCheckBoxEvents)
                return;
            RemoveAgent(periodicTaskName);
        }
        private void ResourceIntensiveCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (ignoreCheckBoxEvents)
                return;
            StartResourceIntensiveAgent();
        }
        private void ResourceIntensiveCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            if (ignoreCheckBoxEvents)
                return;
            RemoveAgent(resourceIntensiveTaskName);
        }


        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            ignoreCheckBoxEvents = true;

            periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask;

            if (periodicTask != null)
            {
                PeriodicStackPanel.DataContext = periodicTask;
            }

            resourceIntensiveTask = ScheduledActionService.Find(resourceIntensiveTaskName) as ResourceIntensiveTask;
            if (resourceIntensiveTask != null)
            {
                ResourceIntensiveStackPanel.DataContext = resourceIntensiveTask;
            }

            ignoreCheckBoxEvents = false;

        }




        private void RemoveAgent(string name)
        {
            try
            {
                ScheduledActionService.Remove(name);
            }
            catch (Exception)
            {
            }
        }

    }
}

             

 d.) and Hit “F5” Smile

 

and below are some screen shots for reference.

  1. App is running and Periodic Agent is enabled to run on every 30 seconds.

image

now after 30 seconds scheduled tasks run and called the Scheduled Task implementation

image

 

and can see that last run status is updated and last run reason is completed.

image

 

Apologies for the Poor formatting.

Hope the code is self explanatory and since the Post is so big after the code blocks and screen shots, I am not including much explanations of this sample. You can read MSDN Reference on How to: Implement Background Agents for Windows Phone, which includes clear cut explanation of the above sample.

References:

Background Agents Overview for Windows Phone

How to: Implement Background Agents for Windows Phone

Windows Phone Development–Developing for 256 MB (low profile) Windows Phone Devices

April 25, 2012 .NET, All, Microsoft, Microsoft SDKs, Mobile-Development, Silverlight, VisualStudio, VS2010, Windows Phone, Windows Phone "Mango", Windows Phone "Tango", Windows Phone 7, Windows Phone 7.0, Windows Phone 7.5, Windows Phone Development, Windows Phone SDK No comments

Microsoft has announced that upcoming Windows Phone 7.5 Refresh code named as “Tango” will have low profile 256 MB devices which would make Microsoft’s entry in to mobile market by delivering low cost Windows Phone devices.

All existing Windows Phone devices are having 512 MB RAM, considering the mid-range or low entry market Microsoft has included the support for 256MB Windows Phone devices.

Feature Limitations on Windows Phone – 256MB Devices

You can use most features offered in Windows Phone OS 7.1 on 256-MB devices with no performance issues. However, generic background agents are not supported on 256-MB devices, and a few additional features should be used with care so you do not exceed the memory limit of the application.

 

Additionally Microsoft has released the restrictions/limitations for 256MB “Tango” (Windows Phone 7.5 “REFRESH”) devices.

  • Windows Phone Marketplace app restrictions – Some processor-intensive apps have memory requirements, and won’t work on phones with 256 MB of RAM. You can check how much memory you have on your phone by tapping Settings > About.
  • Podcast Subscriptions and Video Podcasts – You won’t be able to manage podcast subscriptions on your phone or watch video podcasts if your phone has 256 MB of RAM.
  • Local Scout – You won’t be able to use Local Scout if your phone has only 256 MB of RAM.
  • Fast app switching – This feature will work if your phone has 256 MB of RAM. But applications that use over 90MB will be killed immediately after deactivation.
  • SkyDrive automatic photo upload – You won’t be able to upload pictures automatically to SkyDrive if your phone has only 256 MB of RAM.
  • HD video playback – You won’t be able to play video compressed with some of the listed codecs if your phone has 256 MB of RAM.
  • Background agents – To free up RAM for the foreground on 256MB devices, generic background agents (Periodic Tasks/ResourceIntensiveTasks) are disabled.

 

Tools Required for Development

You would need Windows Phone SDK 7.1.1 Update which includes the support for 256 MB windows Phone device application development. (Of course this is an update which needs to be installed after installing Windows Phone SDK 7.1 )

Windows Phone SDK 7.1.1 Update includes a new 256 MB emulator apart from usual 512 MB emulator and you can toggle between these emulators using the devices menu on Visual Studio 2010.

Windows Phone SDK 7.1.1 Update also includes the support for Windows 8. Now you can install and develop Windows Phone applications on your Windows 8(currently Consumer Preview / BETA).

 

Things to consider when developing for Windows Phone – 256MB Devices

1. Make you application to stay within Application Memory Limits of the Device

Windows Phone – 256MB will have a an Application Memory limit of 90MB, any application that use over 90MB will be immediately killed after deactivation. That means the application will not remain in resident ready to wake up. The application will be killed by OS to save up resources.

While doing development you can check Application Memory Limit on a device using ApplicationWorkingSetLimit parameter for DeviceExtendedProperties.GetValue(string) method.

For example:

 <span class="kwrd">long</span> result = 
    (<span class="kwrd">long</span>)DeviceExtendedProperties.GetValue(<span class="str">&quot;ApplicationWorkingSetLimit&quot;</span>);

 

2. Avoid Generic Background Agents

You would need to have special care when using generic background tasks such as

  • Resource-intensive tasks
  • Periodic tasks

You will have to efficiently manage the resource intensive tasks and empty the task after the completion.

When you try to add one of these background agents in your application using the Add(ScheduledAction) method and passing a PeriodicTask or ResourceIntensiveTask, either on a 256-MB device or on the 256-MB emulator, an InvalidOperationException exception occurs, which indicates that the maximum number of background agents for the device has been reached. (MSDN)

3. Detect the memory limit and change application behavior

If you use a background agent in your application, and you want your application to run on all types of devices, you should check the working memory of the device and not use the background agent on a 256-MB device.

See How to: Disable Features of an Application for a 256-MB Device. (MSDN)

4. Reduce Graphics and Audio Memory Use

When you develop applications and games to run on 256-MB devices, you should be careful about how you use graphics in the game or application. Graphics and audio memory often are not pageable. Too many audio or image resources, textures, and animations can exceed the memory limits of a 256-MB device.

 

5. Consider performance optimization and reduce the application memory usage to maximum optimal

So that the OS will not have to kill your application even if it is deactivated or in dormant stage.

  • Try using the respective launchers and choosers for any purpose relating to it.
  • Avoid having heavy graphics intensive animations.
  • Handle device orientation changes gracefully

 

Restricting our application not installable on 256MB Devices

If your application is resource intensive and you are sure that this application will not work on 256MB devices, you can opt out of getting it installed on 256MB devices.

There is an option called “Requirements” available in WMAppManifest.xml file under “Capabilities” section. and you just have to set attribute value “ID_REQ_MEMORY_90” to the Requirements element .

For example:

&lt;/Capabilities&gt;
&lt;Requirements&gt;
      &lt;Requirement Name=<span class="str">&quot;ID_REQ_MEMORY_90&quot;</span> /&gt;
&lt;/Requirements&gt;

This option will restrict the application getting installed from Windows Phone market place. But still as a developer you can deploy the application to 256 MB Emulator and developer devices.

 

That’s a quick gathering of information from what I learned from MSDN, we need to consider all these aspects when we are programming for an application that will support on all the Windows Phone devices. I hope you gained some knowledge out of this post.  If you need further details, you can refer MSDN: Developing for 256-MB Devices, which is my primary reference source of information as well.

References:

MSDN: Developing for 256-MB Devices

MSDN – How to: Disable Features of an Application for a 256-MB Device.

Windows Phone "Tango" to be renamed to Windows Phone 7.5 “Refresh” and Windows Phone 8 for the future

April 16, 2012 .NET, All, CodeNames, Microsoft, Microsoft SDKs, Mobile-Development, Windows, Windows Mobile, Windows Phone, Windows Phone "Apollo", Windows Phone "Mango", Windows Phone "Tango", Windows Phone 7.0, Windows Phone 7.5, Windows Phone Development, Windows Phone SDK No comments

Microsoft’s announced upcoming Windows Phone OS code named as Windows Phone “Tango” to be renamed to Windows Phone 7.5 Refresh. This is inline with Microsoft’s cloud feature specific Windows Phone OS called as Windows Phone “Apollo” or Windows Phone 8.

 

Windows Phone 7 “Tango” a.k.a Windows Phone 7.5 REFRESH

The upcoming Windows Phone update will be officially referred to as the Windows Phone 7.5 Refresh. Tango will be a minor update, planned to be released in April 2012/May 2012. It will enable Windows Phone to run on low-cost devices with 256 MB RAM and low clock CPU.

Windows Phone "Apollo" a.k.a Windows Phone 8

Apollo is the codename for the next generation of Windows Phone, as officially confirmed by MS at an MSDN seminar in August 2011. This update is also confirmed by Nokia and HTC.

Windows Phone “Apollo” to be termed as “Windows Phone 8”, which is built upon NT Kernel (prior version of Windows Phone are built on CE Kernel). This makes Windows Phone 8 much closer to Windows 8 with cloud integration, multi-core support, external micros SD support, different resolutions etc.

The expected release date for this update is in Q4 2012. ( as per Wikipedia)

List of features coming in Apollo, not yet confirmed by Microsoft, unless otherwise stated: [taken from Wikipedia]

  • Support for multi-cores (confirmed by Nokia)
  • Support for different resolutions
  • NFC support added, including payment and content sharing with WP8 and Windows 8 machines (confirmed by MS (but NFC is partially supported in Tango update, e.g. ZTE Orbit))
  • Carrier control and branding of "wallet" element is possible via SIM or phone hardware
  • Transitions to core components from desktop, including kernel, network stack, security components, and media support
  • Simplified porting of desktop apps to mobile
  • Zune desktop integration scrapped in favor of new, unnamed syncing app
  • Deeper Skydrive integration, including ability to sync data such as music collections (confirmed by MS as part of Live wave 5 update)
  • Xbox Companion app will get Windows 8 partner client
  • Native code support, simplified porting from Android and iOS
  • App-to-app communication and integration
  • Skype client with deep OS hooks that will make it almost identical to placing standard voice calls (confirmed by MS)
  • Camera app now supports "lenses", which allow third parties to skin and add features to camera interface (confirmed by MS)
  • DataSmart tracks and reports usage via app and live tile
  • Gives preferential treatment to WiFi, can automatically connect to carrier-owned hotspots
  • Proxy server will compress websites in Internet Explorer 10 up to 30 percent (IE10 is confirmed by MS)
  • Native 128-bit Bitlocker encryption
  • Support for proprietary, custom built apps to be deployed behind company firewalls

 

[This information is collected from Wikipedia, incase of any irregularities/updates with the POST please leave a comment, I will do the needful to update. My intention with this post is to provide you latest information, some of it might be from a non authentic source. Inconvenience regretted. ]