Silverlight

Windows 8 UX Guidelines for Windows Store apps–PDF

August 16, 2012 .NET, .NET Framework, All, Microsoft, Microsoft SDKs, Silverlight, VisualStudio, VS2012, Windows, Windows 8, Windows 8 apps development, Windows SDK, Windows Store, Windows Store Development No comments

User experience guidelines from Microsoft for Windows Store apps (based on latest RTM release).

Download from Windows 8 UX Guidelines for Windows Store apps

Visual Studio 2012 RTM available for download

August 16, 2012 .NET, .NET Framework, ADO.NET, All, ASP.NET, ASP.NET MVC, Azure Tools, Microsoft, Silverlight, VB.NET, VisualStudio, VS2012, WCF, Web Services, Windows, WinForms, WPF, WWF No comments

Microsoft has released Visual Studio 2012 RTM for MSDN subscribers on 15th AUG 2012. MSDN Subscribers can download it from MSDN here, logging in with your msdn credentials.

image

Those who doesn’t have MSDN subscription can download trial versions from below links from Microsoft Download Center

Download Microsoft Visual Studio Ultimate 2012

There are two types of installers

1. Web Installer (vs_ultimate.exe): – which will download all necessary packages from the download source location before installation.

2. Download a DVD5 ISO image (VS2012_ULT_ENU.iso): you can use it for offline installation. The ISO image contains all the necessary software’s for the installation. You can download the ISO image directly and install it.

Associated download packages:

Download Microsoft Visual Studio 2012 SDK

Download Microsoft Visual Studio 2012 Visualization & Modeling SDK

Download Microsoft Visual Studio Test Professional 2012

Visual Studio 2012 RTMd

August 1, 2012 .NET, .NET Framework, All, ASP.NET, ASP.NET MVC, C#.NET, Microsoft, Microsoft SDKs, Silverlight, VB.NET, VisualStudio, VS2012, WCF, Windows, Windows Phone, Windows Phone Development, Windows Phone SDK, WPF, WWF No comments

Microsoft has announced the RTM(Release to manufacture) of Visual Studio 2012.

For MSDN Subscribers, the bits will be available for download on August 15th. Visual Studio Professional, Premium, Test Professional, and Ultimate with MSDN Subscribers can also sign up for a free, one year developer account for Windows Store today, with Windows Phone developer accounts coming soon.

Microsoft is planning an exciting launch even on September 12th visit http://visualstudiolaunch.com for more details.

Quick comparison sheet of Visual Studio 2012 editions from Microsoft (view comparison)

image

Sources:

http://channel9.msdn.com/posts/Visual-Studio-2012-RTM

http://www.microsoft.com/visualstudio/11/en-us/products/compare

http://blogs.msdn.com/b/somasegar/archive/2012/08/01/visual-studio-2012-and-net-4-5-complete.aspx

http://blogs.technet.com/b/serverandtools/archive/2012/08/01/platform-delivered-microsoft-visual-studio-2012-and-windows-server-2012-released-to-manufacturing-rtm.aspx

 

Visual Studio 11 User Interface Updates Coming in Visual Studio 11 RC(Release Candidate)

May 15, 2012 .NET, .NET Framework, All, ASP.NET, ASP.NET MVC, C#.NET, Microsoft, Microsoft SDKs, Silverlight, Updates, VisualStudio, VS11, WCF No comments

Go through this Visual Studio Team blog about upcoming improvements to Visual Studio 11 User Interface. This will be included as part of Visual Studio 11 RC(Release Candidate) and probably will be released soon by end of May or in June 2012.

For more updates visit the Official blog link below

http://blogs.msdn.com/b/visualstudio/archive/2012/05/08/visual-studio-11-user-interface-updates-coming-in-rc.aspx

Kudos to Visual Studio 11 Team

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.