Follow @PDSAInc October 2011 - Posts - Paul Sheriff's Blog for the Real World

Paul Sheriff's Blog for the Real World

This blog is to share my tips and tricks garnered over 25+ years in the IT industry

Paul's Favorites

October 2011 - Posts

Call for Abstracts for Spring 2012 DevConnections Conference

Calling all Speakers!


My name is Paul Sheriff and I am one of the conference chairs for DevConnections in the Spring of 2012 which will be held at the MGM Grand in Las Vegas. I am looking for some great speakers in 3 different areas of expertise.


1. Fundamentals Track

I need speakers that are adept at teaching business application programmers how to move to .NET, XAML, HTML5, JavaScript and JQuery. I am not looking for a re-hash of old seminar topics. I want new "step-by-step" oriented seminars that show people how to do one or two things well in VS.NET 2010 or later. I would really like step-by-step seminars as much as possible. I am especially interested in those seminars that show people how to move from old style programming to new style programming (Synchronous to Asynchronous, WCF Services, SOA, XAML, HTML5, etc.) I am looking for those seminars that teach the basics to business programmers across a wide variety of topics. Below are the technologies/areas that I think would be good for this track.

- Basics of HTML5

- Basics of JavaScript

- Basics of JQuery

- Moving from Synchronous programming to Asynchronous

- The Basics of C++ for Windows 8

- Suggest a topic…



2. Professional Development Track

This track will focus on the programmer who is moving up to architect, project manager or a development manager. The intent is to present a series of seminars that will help them build their skills in these areas.

- Project Management

- Requirements Gathering

- Estimating

- Architecture

- Suggest a topic…



3. Agile Track

This track will focus on how to implement the Agile process. The attendee should be presented with sessions around implementing Agile, Scrum, etc.


- Intro to Agile/Scrum

- Managing Agile/Scrum Teams

- Top 10 pitfalls of the Agile/Scrum process

- Suggest a topic…




IMPORTANT: We want fresh sessions! If you have presented a topic at DevConnections more than 2 times before, please do not submit those as we will not accept them. We will really be interested in topics around Windows 8, Metro, HTML5 and JavaScript and JQuery.


If you are interested, please let me know by emailing me directly at Here is what I need from you ASAP!

1. A title and short description of your proposed topic

2. Your willingness to present on a minimum of 3 topics

3. You are able to come March 26-March 29, 2012 to Las Vegas to speak on your topics

5. DEADLINE!  I need all of this by October 31, 2011

Please ALSO enter your abstract at


Abstract Format

Please really think about your Title and Abstract. I would prefer you to have it in the following format.


Title: The title should be very action oriented and explain exactly what you will get from this session. Think “Marketing and Sales”! You are selling your session to the attendees. Using numbers in your title are a great way to gather interest, for example; “Top 10 tips for ____”, “The 20 things you need to know to _____”, “You can learn _____ in just 75 minutes”, etc.


Description: Use a lot of action sentences and explain each demo and each point that the attendee will get from attending this seminar. Really sell this seminar to the attendee in here. If possible we would like to have the user walk away with a class, a DLL, a reusable widget, flash cards, a document with step-by-step instructions, or a set of concrete techniques from this session. Give some value to the attendee. Make this “Take Away” the last sentence in your abstract.


Please keep the abstracts under 200 words each and in one paragraph. No bulleted items and line breaks, and please use a spell-checker. You need to use the web-based tool to submit them officially, but send to me too please. Please submit at least 3 abstracts, but it would help your chances of being selected if you submitted 5 or more abstracts. Also, you are encouraged to suggest all-day pre or post conference workshops as well. We need to finalize the conference content and the tracks layout in just a few weeks, so we need your abstracts no later than October 31, 2011. NO EXECPTION will be granted on late submissions!


What you will get if selected:

- $500 per regular conference talk.

- Compensation for full-day workshops ranges from $500 for 1-20 attendees to $2500 for 200+ attendees.

- Airfare allowance of up to $500. If you are international, you will have to cover the rest.

- Hotel stay paid by the conference.

- Free admission to the conference.

- Speaker party.

- Lots of fun!



Paul D. Sheriff


PDSA, Inc.

Microsoft Regional Director, Southern California | (714) 734-9792, ext. 224



PDSA, Inc. is a Microsoft Partner in Southern California.

We specialize in Architecture Planning & Assessment, Custom Software Development, .NET and SQL Server.



Retrieving Data: From Synchronous to Asynchronous

As technology keeps moving on, we as developers are continually challenged to learn new ways of doing our jobs. Many years ago (starting as far back as Visual Basic 4.0) the movement was toward OOP and creating N-Tier applications. This meant wrapping up the data returned from DAO, RDO or ADO into classes and collections of classes. .NET came along and we started using ADO.NET to retrieve data. However, usage of classes and collection classes changed very little, at least conceptually. In .NET 2.0 Generics were introduced, but this just helped simplify our code. Again, our basic class structure changed very little.

If you were a normal desktop developer (Windows Forms) or an ASP.NET developer you were able to simply connect to your database, retrieve your data, and life was good. However, as more devices have exploded into our world, we are forced to learn new ways to consume our data. Most prevalent is the use of web services or Service Oriented Architecture (SOA). Luckily, web services can be consumed from desktop apps, web apps, and mobile apps. If you are doing desktop apps and web apps, you can most likely consume these services using a synchronous model. If you are using Silverlight, HTML5 with JS or other mobile applications, you will have to use an asynchronous model. Moving from synchronous to asynchronous is not too difficult; it just takes a little different style of programming.

The Product Class

In the sample code you will be using a Product class. This class has just four properties and is used to store a single product. This class is shown below:

public class Product
  public int ProductId { get; set;}
  public string ProductName { get; set; }
  public DateTime IntroductionDate { get; set; }
  public decimal Price { get; set; }

You can then create a collection of Product objects using a generic List<Product>. Of course you can use any method you want for creating a collection of Product objects.

Create a Collection of Products

The code to create a collection of Product objects has not fundamentally changed in years. In the code below I will use ADO.NET to just keep things simple. Feel free to use LINQ to SQL, the Entity Framework, or any other method you want. Just realize that under the hood, all of these technologies perform this same type of code.

using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public List<Product>  GetProducts()
  List<Product> ret = new List<Product>();
  DataTable dt = new DataTable();
  SqlDataAdapter da;

  da = new SqlDataAdapter("SELECT * FROM Product",


  foreach (DataRow item in dt.Rows)
    Product prod = new Product();

    prod.ProductId = Convert.ToInt32(item["ProductId"]);
    prod.ProductName = Convert.ToString(item["ProductName"]);
    prod.IntroductionDate =
    prod.Price = Convert.ToDecimal(item["Price"]);


  return ret;

In the code above you create a SqlDataAdapter object which is used to fill up a DataTable. You iterate over the rows in the DataTable and create an instance of a Project class. You fill each property of the Product object with the corresponding data from the column you retrieved from the Product table. This new Product object is added to the collection class. Again, this type of code has not changed in over 15 years. You would have written very similar code in Visual Basic, as far back as version4.0.

Accessing Data Directly (The Old Way)

From a Windows Forms, WPF or ASP.NET application you can use the above code directly from your front end to load data into a list box or other list-type control. In the sample code you can download with this article, there is a user control with a Load Products (Local) button (Figure 1).

Figure 1: Samples to load Product Data

Figure 1: Samples to load Product Data

When you click on this button you run the following code:

private void btnLoad_Click(object sender, RoutedEventArgs e)
  List<Product> coll;

    coll = GetProducts();

    lstData.DataContext = coll;
  catch (Exception ex)

In this click event you simply call the GetProducts() method directly in a synchronous manner. While this is fine for a normal desktop application, if you wish to use this code in Silverlight, Windows Phone, Windows 8 Metro, or any of the other mobile devices you will need to use a service. To start this process, let’s take a look at how to create a service using WCF and then call this service synchronously. Later in this article you will then call this same WCF service asynchronously.

Accessing Data Synchronously From a Web Service

Creating a service application is very easy in  Visual Studio. You simply choose New Project and select WCF from the list of installed templates. Choose the WCF Service application from the list of template projects. Give this new service project a name of ProductService. Next, delete the IService.cs and Service.svc files. It is easier to delete and just add a new name than to rename the files and classes. Now add a new WCF Service called ProductService. This creates two new files in your project; IProductService.cs and ProductService.svc. Into the IProductService interface you will define a contract that specifies a method name and the return value from that method.

public interface IProductService
  List<Product> GetProducts();

In the code behind of the ProductService.svc you will then drop in the GetProducts() method you wrote before. You will need to add a <connectionStrings> element in the Web.config file that the service can use to connect to the database where your product data resides.

Back in your client code, you now need to add a Service Reference to your WCF service. Name this service ProductSyncServiceReference. In the sample for this article, which is named SyncToASync, you will then need a using statement to use the classes in the namespace created by the Service Reference dialog.

using SyncToASync.ProductSyncServiceReference;

Next, you write code under the Load button’s click event procedure to call the GetProducts method in this WCF service. The generated code creates a class called ProductServiceClient that knows how to connect to your service endpoint. You will create an instance of this class and call the GetProducts method as shown in the code below.

private void btnLoad_Click(object sender, RoutedEventArgs e)
  List<Product> ret;
  ProductServiceClient productService =
    new ProductServiceClient();

    ret = productService.GetProducts();

    lstData.DataContext = ret;
  catch (Exception ex)

This code calls the WCF service, the service gathers the data, and then the collection of Product objects is returned from the service. All of this happens synchronously, which means that until the service calls finishes your code and UI are frozen on this one line of code.

Let’s now look at how to make this call asynchronously and thus free up your UI and other code to run while the code to fetch the data waits for the data from the service.

Accessing Data Asynchronously From a Service

You can call this same WCF Service asynchronously from your WFP, Windows Forms or ASP.NET application (as well as Silverlight and Windows Phone). When you create the service reference in your WPF application you will need to click on the Advanced… button (Figure 2) to specify that you wish to generate asynchronous method calls (Figure 3). You do not need to do this step with Silverlight and Windows Phone as this dialog knows that the only option is asynchronous in these environments.

It is a good idea to also choose System.Collections.Generic.List in the Advanced dialog. What this option does is to map any List<T> objects that you return from your WCF service are returned as a generic collection. By default, WCF services will return an array because that is more usable by other consumers other than .NET. Since we are using .NET, we can take advantage of Generics.

Figure 2: Click the Advanced Button to create asynchronous code

Figure 2: Click the Advanced Button to create asynchronous code

Figure 3: Change the async and collection types

Figure 3: Change the async and collection types

Now in your client side code, you will again need to add a using statement to bring in the namespace for the asynchronous web service reference.

using SyncToASync.ProductAsyncServiceReference;

Now you write your code in the Click event for your button. This code will be different from the synchronous version of this code. First you need to create an instance of the ProductServiceClient outside of any event procedures in your window as shown below:

ProductServiceClient _ProductService =
  new ProductServiceClient();

You need the variable that points to the ProductServiceClient to be defined as a field in your C# class because you need to call a method on this object in one method, but you will need to close the connection through this object in another method. Thus, you need to define this variable at the class level so all methods and events in this class can use this variable.

When you clicked on the “Generate asynchronous operations” check box this causes the code generator to create a “Completed” event and a “GetProductsAsync()” procedure. You first hook up an event procedure to call back into after the data has been gathered asynchronously and returned back to the client. Next you call the GetProductsAsync method to start the asynchronous process of gathering the data in the background.

private void btnLoad_Click(object sender, RoutedEventArgs e)
  _ProductService.GetProductsCompleted += new


In the “Completed” event procedure you will get an event argument that contains a “Result” property. In this property is the return value from the call to your web service. In this case it is a generic List collection of Product objects. You can take that data and put it into the DataContext property of your list box. If you have bound your list box correctly, then the product data will be displayed after the call to the Completed event is finished. At this point you should also close the connection to the Product service.

void client_GetProductsCompleted(object sender,
 GetProductsCompletedEventArgs e)
  lstData.DataContext = e.Result;



Asynchronous programming will become more and more prevalent with Windows 8 as that will be the only supported model for most of the APIs and certainly for any Metro-style application. You can start learning and using Asynchronous programming today and prepare for the future. Start slowly by adding a few calls to a service from your existing applications. Have fun!

NOTE: You can download this article and many samples like the one shown in this blog entry at my website. Select “Tips and Tricks”, then “Synchronous to Asynchronous Data” from the drop down list.

Good Luck with your Coding,
Paul Sheriff

We frequently offer a FREE gift for readers of my blog. Visit for your FREE gift!

More Posts