Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Frictionless WCF service consumption in Silverlight - Part 3: Benefits of transparent asynchrony with respect to unit testing

, 26 May 2011
Simplifying unit testing of View Models which use asynchronous WCF service calls.
FrictSLUnitTest.zip
Source
Sample.Silverlight.WCF
Infrastructure
Actions
Services
Properties
Shared
Utility
Views
Sample.Silverlight.WCF.Tests
Properties
Sample.Silverlight.WCF.Tests.Clumsy
Properties
DataSources
Sample.Silverlight.WCF.Web.Services.Task.datasource
Service References
ServiceReference1
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
TaskService.disco
TaskService.wsdl
ServiceReferences.ClientConfig
Sample.Silverlight.WCF.Tests.Clumsy.Web
Properties
Sample.Silverlight.WCF.Web
Properties
Services
TaskService.svc
Tools
NUnit
nunit.framework.dll
nunit.silverlight.dll
Rhino.Mocks
Castle.Core-Silverlight.dll
Castle.DynamicProxy-Silverlight.dll
Rhino.Mocks 3.5.Silverlight.dll
#region Author

//// Yevhen Bobrov, http://blog.xtalion.com 

#endregion

using System;
using System.Threading;

namespace Sample.Silverlight.WCF.Infrastructure.Actions
{
	public abstract class DispatchAction : IAction
	{
		public event EventHandler Completed;

		readonly SynchronizationContext dispatcher = SynchronizationContext.Current;

		protected void SignalCompleted()
		{
			EventHandler handler = Completed;

			if (handler == null)
				return;

			if (dispatcher == null)
			{
				handler(this, EventArgs.Empty);
				return;
			}

			dispatcher.Post(x => handler(this, EventArgs.Empty), null);
		}

		public abstract void Execute();
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

About the Author

Yevhen Bobrov
Software Developer http://blog.xtalion.com
Ukraine Ukraine
No Biography provided
Follow on   Twitter

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 26 May 2011
Article Copyright 2011 by Yevhen Bobrov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid