Windows Store Apps Using HTML5 – UI Virtualization (Part 4 of 4)

Check out Part 4 of 4 in my blog series for Magenic featuring Windows Store Apps Using HTML5 – UI Virualization (Part 4 of 4). In this article I introduce UI Virtualization using asynchronous data template functions. The performance of Windows Store Apps is important to consider, especially when handling large collections of data. When displaying the collection, performance can be degraded. In part three, first steps were taken to alleviate the performance problems that can arise under heavy data usage. Part four will describe further performance improvements using UI virtualization.

Asynchronous data template functions enable substantial user experiences by keeping an app responsive and informative. This article’s implementation of UI virtualization relies on these concepts of asynchronous data template functions. The following sections will describe the main components of the implementation along with the differences from simple asynchronous data template functions. First to be examined is the markup.

Read more here:

http://magenic.com/Blog/WindowsStoreAppsUsingHTML5UIVirtualization

Windows Store Apps Using HTML5 – Asynchronous Data Template Functions (Part 3 of 4)

Check out Part 3 of 4 in my blog series for Magenic featuring Windows Store App Using HTML5 – Asynchronous Data Template Functions. In this article I introduce asynchronous data template functions. The nature of Windows Store apps is asynchronous. To follow along with this asynchronous nature (as Windows Store app developers should), this article will detail asynchronous template functions.

Asynchronous template functions provide enhanced usability by allowing a user to interact with the app during information retrieval while keeping the user aware of incoming information. This is essential in providing the user with an optimal experience.

Read more here: 

http://magenic.com/Blog/WindowsStoreAppsUsingHTML5AsynchronousDataTemplateFunctions

Windows Store Apps Using HTML5 – Basic Data Template Functions (2 of 4)

Check out Part 2 of 4 in my blog series for Magenic featuring Windows Store App Using HTML5 – Basic Nested Data Templates. In this article I introduce data template functions. The potential of data template functions easily stretch beyond added scalability. They give the developer complete control over the presentation of each data object. By taking template functions into account when designing Windows Store Apps, the app will have the potential of a very powerful data presentation layer.

Read more here: http://magenic.com/Blog/WindowsStoreAppsUsingHTML5BasicDataTemplate

Windows Store Apps Using HTML5 – Basic Nested Data Templates (Part 1 of 4)

Check out Part 1 of 4 in my blog series for Magenic featuring Windows Store App Using HTML5 – Basic Nested Data Templates. In this article I introduce nested data templates where data templates have data templates! Like basic templates, there are four necessary components when working with nested templates: Template, Data Source, Binding, and Render Target. Building off basic templates, nested templates provide further flexibility by adding more levels of control over the presentation of data. Using the methods described will allow the potential for indefinite levels of nesting. This greatly increases the flexibility of data presentation. Please note that this article will only go as far as a single nested template.

Read more here: http://magenic.com/Blog/WindowsStoreAppsUsingHTML5(1of4)

Run a System.Action Instantiation Asynchronously

Here is the second article in the Extension Me series. The Extension Me series focuses on various uses of Extension Methods in .NET and primarily uses C# as the language of choice. This article will briefly focus on the topic of Asynchronous Programming by extending System.Action delegates. Using the extension method, any code wrapped in an instantiation of System.Action delegates can be executed asynchronously. The assumptions made about the reader are: has experience with the basics of programming in C# and knows what extension methods are. Please be advised: the implications of asynchronous programming are not to be ignored for severe consequences can occur.

Not only is asynchronous programming fun and beneficial (if used correctly), it is becoming an essential skill as Windows 8 is introduced. Although the implementation of the following asynchronous pattern is incompatible with Metro-style WinRT apps, the theory of asynchronous programming will surely be applicable. More information on Asynchronous Programming can be found at Visual Studio Asynchronous Programming where How-To videos, whitepapers, samples, and walkthroughs are available.

Below is the implementation of the extension method:

public static class ActionExtensions
{
	public static void Async(this Action @this)
	{
		var thread = new Thread(@this.Invoke);
		thread.Start();
	}
}

The code snippet above shows how extension methods can introduce the beauty of System.Action and System.Threading.Thread objects working together. The Action and the Thread are very close. An essential function of System.Action is wrapping a block of executable code while an essential function of System.Threading.Thread is wrapping a block of execution. By embracing these two abilities, code can be executed asynchronously just by wrapping it in an Action delegate. Here is an example:

public void ReturnsQuick()
{
        new Action(() =>
        {
                 //Long Running Code here runs on a separate thread...
        }).Async();
}

When the ReturnsQuick method is called, it creates a new instance of an Action passing a lambda containing “long-running code”. Using the extension method created previously, the code is executed on a separate thread. The code is now asynchronous and, as the name suggests, the ReturnsQuick method returns immediately after calling Async().

As mentioned above when introducing the topic of this article, there are plenty of caveats that must be addressed before adopting this approach (especially application-wide). Shared resource is one of the most important things to consider. If two threads try to access a single resource at the same time, one of them has to loose! Please take a look at the available pdf, “Threading in C#” by Joseph Albahari for a more detailed explanation of proper asynchronous approaches.