Silverlight Developers, Take NoteSilverlight Developers, Take Note

Beta tool checks how an app runs across multiple threads

information Staff, Contributor

January 20, 2011

3 Min Read
information logo in a gray background | information

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 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. (That is, 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, so 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.

Gastón Hillar is the author of Professional Parallel Programming With C#. Write to us at [email protected].

Read more about:

20112011
Never Miss a Beat: Get a snapshot of the issues affecting the IT industry straight to your inbox.

You May Also Like


More Insights