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

Automatic Implementation of the Event-Based Asynchronous Pattern

, 26 Nov 2008 CPOL
Implement the event-based asynchronous pattern automatically with this code generator
asyncgen_demo.zip
asyncgen_demo
ClassLibrary1
bin
Debug
ClassDiagram.cd
Properties
Client
bin
Debug
Properties
Settings.settings
Server
bin
Debug
Properties
asyncgen_src.zip
asyncgen_src
AsyncClientGeneratorLib
asyncgen.snk
ClassDiagram.cd
fxReflection.proj
Properties
Properties
TestAssembly
Properties
TestClientCpp
app.ico
TestClientCSharp
Properties
TestClientVB
My Project
Application.myapp
Settings.settings
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace AsyncGen
{
    /// <summary>
    /// Holds the final output of the operation.
    /// </summary>
    /// <typeparam name="TOutput">The type of the output.  If the operation has multiple outputs, a value type that encapsulates all of them.</typeparam>
	public class AsyncCompletedEventArgs<TOutput> : AsyncCompletedEventArgs
	{
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="output">The output of the operation.</param>
        /// <param name="error">The exception that was thrown by the operation, if it failed.</param>
        /// <param name="cancelled">A boolean value indicating whether the operation has terminated due to a cancellation request from the client.</param>
        /// <param name="userState">An object that uniquely identifies a specific invocation of the operation.</param>
		public AsyncCompletedEventArgs(TOutput output, Exception error, bool cancelled, object userState)
			: base(error, cancelled, userState)
		{
			this.output = output;
		}

        /// <summary>
        /// The output of the operation.  If the operation has multiple outputs, a <c>struct</c> that encapsulates all of them.
        /// </summary>
		public TOutput Output
		{
			get
			{
				RaiseExceptionIfNecessary();
				return output;
			}
		}

		private TOutput output;
	}

    /// <summary>
    /// Defines the signature for a handler of the completion event.
    /// </summary>
    /// <typeparam name="TOutput">The type of the output.  If the operation has multiple outputs, a value type that encapsulates all of them.</typeparam>
    public delegate void AsyncCompletedEventHandler<TOutput>(object sender, AsyncCompletedEventArgs<TOutput> args);
}

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 Code Project Open License (CPOL)

Share

About the Author

Ron A Inbar
Software Developer (Senior) Philips Healthcare
Israel Israel
I got my B.Sc. in Mathematics and Computer Science from Tel Aviv University in 1997. Since then I have developed software in UNIX, Win32 and .NET. I currently live in Haifa.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Nov 2008
Article Copyright 2008 by Ron A Inbar
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid