Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Silverlight Developers, Take Note

Gaston is the author of Professional Parallel Programming with C#.

Microsoft’s latest service pack for Visual Studio 2010 has something Silverlight application developers will find particularly useful. It’s the addition of performance wizards to do profile concurrency, which lets them know if multithreaded apps are executing properly. The tool spits out a graph showing how each thread is behaving — especially important for developers to make sure multithreaded applications are scaling properly on newer multicore machines. Visual Studio 2010 Premium and Ultimate versions introduced powerful concurrency profiling features for Windows applications through new options in the Performance Wizard. However, those performance profiling tools weren’t available for Silverlight projects.

Visual Studio 2010 Service Pack 1 Beta 1 — or SP1 Beta 1 — removes this restriction and lets you select a Silverlight project as the target for a profiling session. Thus, you can visualize the behavior of a multithreaded Silverlight application.

By default, a Silverlight application uses multithreaded code under the hood, which you have to take into account when profiling concurrency. (Meaning, don’t be confused by the additional threads that will result in the concurrency analysis.) The first time you run a concurrency profiling session for a Silverlight project, you might get a bit overwhelmed by the number of worker threads, even if your code just works on the main thread. However, the profiler has detailed information that will help you focus on your threads.

When you use the profiling tools with a Silverlight project, it’s very important to finish the execution of the application as soon as possible to avoid collecting unnecessary information. Once the code you want to analyze has finished its execution, you must close the browser with the Silverlight application so that your profiling session will be properly targeted.

The profiler generates a collection of graphs that provide information about the behavior of a multithreaded Silverlight application, and these can be used to detect common problematic patterns in parallelized applications. However, it’s best to isolate any suspicious algorithm in a simple application to shorten its detailed analysis. If you try to profile a very complex Silverlight application, the process will require more time and effort to detect certain important problems, such as a serialized execution. The result of a profiling session provides detailed information about CPU utilization, the threads, and how these threads are mapped to the available logical cores.

Because Silverlight 4 doesn’t let you work with the Task Parallel Library introduced in .NET Framework 4, it’s still necessary to use threads to take advantage of multicore functionality in your Silverlight applications. The threads view provides timelines and the execution profile of each thread. You can use this information to optimize your code.

Silverlight 4 is becoming very popular for developing line of business applications and Rich Internet Applications that consume data and services. And if you use asynchronous managed APIs, such as SharePoint Silverlight Client Object Model, you will work with multithreaded code, because the callbacks run on new threads. You can use the SP1 Beta 1 concurrency profiling features to optimize the execution of these asynchronous calls and translate the available multicore power into application performance.

As a bonus, SP1 Beta 1 includes the most updated version of Silverlight 4 Tools. The debugger adds support for IIS Express, and you’ll also welcome the new local Help Viewer — a client application that makes it easier and faster to navigate through the help contents. If you work with Silverlight 4 integrated into SharePoint 2010 sites, the IntelliTrace support for SharePoint projects will improve your debugging experience. SP1 Beta 1 comes with a go live license; therefore, you can use it for production- related work. However, keep in mind it’s still a beta version, with all that entails, and isn’t yet compatible with Visual Studio Async CTP.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.