.NET Tips and Tricks

Blog archive

Two Questions with Mark Miller

As parallel processing becomes main stream, tool vendors are moving to provide more support. See my conversation with Stephen Forte of tool vendor Telerik, who sees parallel processing and multicore support as having the single biggest impact on .NET development in the near future. The latest version of DevExpress' Refactor! and CodeRush (reviewed recently here), for instance, support new refactorings for parallel processing. I spoke with Mark Miller, chief scientist at DevExpress and a C# MVP, about refactoring in .NET.

Peter Vogel: What are the challenges and opportunities in supporting refactoring for parallel processing in .NET 4 and Visual Studio 2010?
Mark Miller: The biggest challenge we faced was the moving target, as these refactorings were designed and built almost a year before .NET 4.0 shipped. With regard to opportunities, supporting parallelization continues our long history of supporting the latest technologies developed by the language and framework teams at Microsoft. Also, refactorings that convert old technology into new make it easier for customers to learn and adopt the new technology.

PV: What was hard to implement?
MM: Our biggest challenge was in the implementation of the "Execute Statement Asynchronously (FromAsync)" refactoring. That refactoring converts existing code like this:

      using (Document document = new Document())
{
document.Print();
}

Into code like this that takes advantage of the support for parallel processing:

        using (Document document = new Document())
{
var t = Task.Factory.FromAsync(document.BeginPrint, document.EndPrint, null);
t.Wait();
}

This assumes that the Document class looks like this:

  public class Document: IDisposable
{
public void Print()
{
//...
}

public IAsyncResult BeginPrint(AsyncCallback asyncCallback, Object obj)
{
IAsyncResult result = null;
//...
return result;
}

public void EndPrint(IAsyncResult iAsyncResult)
{
// ...
}

public void Dispose()
{
// ...
}

// ...
}

Notice that in the conversion above we go from a Print method call into referencing BeginPrint and EndPrint methods passed as parameters into the FromAsync method. The availability check for this refactoring is complex, as it needs to start with the document local variable, then move to the Document class, then search that class (and its ancestors) for methods called BeginXxxxx and EndXxxxx (where Xxxxx" matches "Print" in this case) and ensure those methods have the expected signature.

Posted by Peter Vogel on 06/06/2010 at 1:16 PM


comments powered by Disqus

Featured

  • What's New in Visual Studio 2019 v16.5 Preview 2

    The second preview of Visual Studio 2019 v16.5 has arrived with improvements across the flagship IDE, including the core experience and different development areas such as C++, Python, web, mobile and so on.

  • C# Shows Strong in Tech Skills Reports

    Microsoft's C# programming language continues to show strong in tech industry skills reports, with the most recent examples coming from a skills testing company and a training company.

  • Color Shards

    Sharing Data and Splitting Components in Blazor

    ASP.NET Core Version 3.1 has at least two major changes that you'll want to take advantage of. Well, Peter thinks you will. Depending on your background, your response to one of them may be a resounding “meh.”

  • Architecture Small Graphic

    Microsoft Ships Preview SDK, Guidance for New Dual-Screen Mobile Era

    Microsoft announced a new SDK and developer guidance for dealing with the new dual-screen mobile era, ushered in by the advent of ultra-portable devices such as the Surface Duo.

  • How to Create a Machine Learning Decision Tree Classifier Using C#

    After earlier explaining how to compute disorder and split data in his exploration of machine learning decision tree classifiers, resident data scientist Dr. James McCaffrey of Microsoft Research now shows how to use the splitting and disorder code to create a working decision tree classifier.

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events