>
 Thursday, August 16, 2007

Today I completed a webcast as part of a 15 part series - today's subject concurrency, throughput and throttling. I received some questions about callback and Windows client applications that I thought I would elaborate on here. In fact, I went a little overboard and created a bunch of samples that would illustrate the behavior of services and clients when you have a Windows client, a service with a callback contract (thus, two-way communication) and various WCF settings at the client and service that relate to concurrency, multithreading, synchronization with the UI thread, and so on.

The following table summarizes various settings at the client, service and callback and the resulting behavior at runtime. Here's the breakdown for each column:

  • Callback Sync Context - refers to the UseSynchronizationContext setting for the CallbackBehaviorAttribute on the client callback object.
  • Callback Concurrency Mode - refers to the ConcurrencyMode setting for the CallbackBehaviorAttribute on the client callback object.
  • Service Operation - Indicates if the service contract operations are one-way or two-way.
  • Callback Operation - Indicates if the callback contract operations are one-way or two-way.
  • Service Concurrency Mode - refers to the ConcurrencyMode setting for the ServiceBehaviorAttribute on the service type.
  • Resulting Behavior - when the corresponding sample is run, what happens?

I have also uploaded sample code for each of these scenarios, numbered in order of table row description below. Get the code here.

Callback Sync

Context

Callback Concurrency Mode

Service Operation

Callback Operation

Service Concurrency Mode

Resulting Behavior

True/

False

Single/

Reentrant/

Multiple

One-way/

Two-way

Two-way

Single

These are defaults. InvalidOperationException at the service. Operation would deadlock calling the client application since the callback is two-way and reentrancy isn’t possible.

True

Single/

Reentrant/

Multiple

Two-way

Two-way

Reentrant/

Multiple

Service able to call client, but client is blocked because of outgoing call.

False

Single/

Reentrant/

Multiple

Two-way

Two-way

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. If client callback object tries to communicate with UI thread (i.e., setting properties of controls) it will block.

False

Single

One-way

Two-way

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. Client callback object can communicate with UI thread using Invoke() from callback thread. Client can issue multiple calls to service but only one callback can be processed at a time.

False

Multiple

One-way

Two-way

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. Client callback object can communicate with UI thread using Invoke() from callback thread. Client can issue multiple calls and multiple callbacks can be processed at a time.

False

Multiple

One-way

One-way

Single/

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. Client callback object can communicate with UI thread using Invoke() from callback thread. Client can issue multiple calls and multiple callbacks can be processed at a time.

False

Multiple

Two-way/

Multi-threaded Client

 

Two-way

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. Client callback object can communicate with UI thread using Invoke() from callback thread. Multiple calls from client can be processed at the service, and multiple callbacks can be processed at the client.

False

Multiple

Two-way/

Multi-threaded Client

Two-way

Reentrant/

Multiple

Service able to call client, client callback object is not blocked. Client callback can communicate with UI thread using Invoke() from callback thread. Multiple calls from client can be processed at the service, and multiple callbacks can be processed at the client.

Here is a summary of considerations.

  • Contract design:
    • Make callback operations one-way. If this isn’t possible, make the service reentrant. Prefer one-way callbacks since most likely the service doesn’t care about responses.
    • If service operations will notify clients with a callback, make them one-way as well.
  • Exception handling:
    • Remember that uncaught exceptions invalidate service, client and callback channels where sessions are involved. Two-way communication can only happen over duplex, thus there is a transport session (TCP, named pipes) or HTTP session (using reliable sessions over WSDualHttpBinding). 
    • Throw faults for known exceptions unless you want the client to be forced to recreate the proxy and start a new session. That includes clients – who should not allow exceptions to flow back to the service during a callback unless they intend to destroy the session.
    • To avoid destroying the session: if callback operations are one-way, swallow the exception after handling it at the client; if callback operations are two-way, report a fault to the service in response.
  • Windows client issues:
    • Always disable synchronization with the UI thread for callback objects, by setting UseSynchronizationContext to false in the CallbackBehaviorAttribute. 
    • Multithreaded clients should invoke services on another thread (can use asynchronous proxies) when callbacks or long running service operations are involved. This prevents UI thread from blocking during call, allows callbacks to communicate freely with UI.
    • Use Invoke() to communicate with UI from the callback thread. 
    • Don’t forget to protect other client state if the callback object supports multiple concurrent callbacks. That means the ConcurrencyMode setting is Multiple in the CallbackBehaviorAttribute.
Technorati Tags: , ,
8/16/2007 1:20 AM .NET 3.0 | WCF  | Comments [5]  |  View reactions  |  Trackback
 Tuesday, August 14, 2007

In preparation for our upcoming .NET 3.5 Roadshow  (http://www.dotnetroadshow.com/) I am posting setup instructions for those who need some tips on setting up an environment to work with the latest technologies. If you can start using Visual Studio 2008 (Beta 2 available now), I highly recommend it - it gives you the latest .NET 3.0 tools for your WCF, WPF and WF projects. But, for those still using Visual Studio 2005, I have provided those links here as well.

Technorati Tags: , ,

8/14/2007 2:59 PM .NET 3.0 | .NET 3.5 | VS 2008  | Comments [14]  |  View reactions  |  Trackback
 Sunday, July 08, 2007

On my newest machine, I have a fresh installation of Windows Vista Ultimate that I installed Office 2007 to. After running Outlook 2007 the first time, Office 2007 goes through a configuration step that requires a reboot, but I received this error:

Error 1719: The Windows Installer service could not be accessed

There is an updated KB entry with recommended steps to fix the problem here: http://support.microsoft.com/kb/315346/en-us

This entry doesn't mention Vista at all, and in fact, I was able to repair the problem on my Vista machine just by running the following command line instructions, in this order:

msiexec /unregister

msiexec /register

So, if you have this problem, give that a go first...then consult with the KB entry if you still have issues.

7/8/2007 10:04 PM  | Comments [0]  |  View reactions  |  Trackback
 Sunday, June 24, 2007

I delivered 15 webcasts on WCF this summer, from July through September. Each webcast is 1 hour in length, touching on the fundamentals and practical approaches for your WCF development efforts. Here are the links to the archived webcasts!

NOTE: On page 3 of the registration process you can print the slides.

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 01 of 15): Overview

Monday, July 02, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344312&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 02 of 15): Contracts

Monday, July 09, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344314&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 03 of 15): Contract Versioning

Wednesday, July 11, 2007 10:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344318&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 04 of 15): Exceptions and Faults

Friday, July 13, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344322&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 05 of 15): Bindings

Monday, July 23, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344330&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 06 of 15): Hosting

Wednesday, July 25, 2007 10:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344338&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 07 of 15): Messaging Patterns

Friday, August 10, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344342&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 08 of 15): Instancing Modes

Monday, August 13, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344344&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 09 of 15): Concurrency, Throughput, and Throttling

Wednesday, August 15, 2007 10:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344346&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 10 of 15): Security Fundamentals

Friday, August 24, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344348&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 11 of 15): Federated Security

Monday, August 27, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344351&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 12 of 15): Reliable Messaging

Wednesday, August 29, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344353&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 13 of 15): Transactions

Monday, September 03, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344355&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 14 of 15): Message Queuing

Wednesday, September 05, 2007 9:00 AM Pacific Time (US & Canada)

o http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344357&Culture=en-US

· MSDN Webcast: Windows Communication Foundation Top to Bottom (Part 15 of 15): Extensibility

Friday, September 07, 2007 9:00 AM Pacific Time (US & Canada)

http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032344359&Culture=en-US

6/24/2007 7:11 PM  | Comments [44]  |  View reactions  |  Trackback
 Thursday, June 14, 2007

A big thanks to everyone who attended my two sessions at Tech Ed Orlando on CardSpace. I also really enjoyed all of the great questions during and after each session, I can see a lot of momentum building around CardSpace, other identity selectors and providers, and approaches to federated identity models. Very exciting stuff indeed.

As for my code, as I said I had already posted the code beforehand, but I have updated the ASP.NET sample slightly to reflect how I associated the username and password with a unique identifier for a personal card. You can download the latest version of my CardSpace samples here.

Enjoy!

6/14/2007 4:45 PM  | Comments [21]  |  View reactions  |  Trackback
 Friday, June 08, 2007

Please see this updated post from the Dev Connections conference in Orlando (just past) for the code samples and references for the performance talk I stepped in to do. Some people were asking me about the post, and the update had not shown up on the blog...now it is there :)

See this link.

6/8/2007 5:29 PM  | Comments [1]  |  View reactions  |  Trackback
 Wednesday, April 04, 2007

This is great news from Soma's blog. Now Expression Web and Blend (soon) will be available to MSDN Premium subscribers. Many of us have been hearing feedback on the subject and relaying this feedback to Microsoft...nice to know they are listening!

http://blogs.msdn.com/somasegar/archive/2007/04/03/listening-to-your-feedback-expression-and-msdn.aspx

4/4/2007 11:50 AM  | Comments [0]  |  View reactions  |  Trackback
 Monday, April 02, 2007

Once again a fantastic conference in Orlando. Dev Connections just keeps getting better and I always enjoy being part of it. Not to mention the weather in Orlando isn't bad!

Here are links to my code samples for each talk I delivered. Enjoy!

.NET Technology Roadmap Tutorial

ASP.NET and WCF

ASP.NET and CardSpace

WCF Federated Security

 WCF Contracts and Versioning

ASP.NET Performance (Updated 06/07/2007)

Ok people, I had this in my Windows Live Writer to send a long time ago, and somehow it did not post...but since I haven't posted in a while I didn't notice. Many apologies for the delay. Does the "better late than never" statement apply here? I hope so...

 

4/2/2007 3:32 PM ASP.NET | CardSpace | Speaking/Events | WCF  | Comments [12]  |  View reactions  |  Trackback
    ON THIS PAGE
    SEARCH
    CATEGORIES
    ARCHIVES
    BLOGROLL

Designed by NUKEATION STUDIOS