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;

namespace AsyncGen
{
    /// <summary>
    /// Defines the progress event which is raised on the client in response to a callback from the server.
    /// </summary>
    /// <remarks>This attribute should be applied to the methods of the callback interface.</remarks>
	[AttributeUsage(AttributeTargets.Method)]
	public sealed class GenerateProgressEventAttribute : Attribute
    {
        #region Construction

        /// <summary>
        /// Constructs a new instance of the <see cref="GenerateProgressEventAttribute"/> class.
        /// </summary>
        /// <param name="eventName">Same as the <see cref="EventName"/> property.</param>
		public GenerateProgressEventAttribute(string eventName)
		{
			this.eventName = eventName;
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// The name of the event to generate.
        /// </summary>
        public string EventName
        {
            get { return eventName; }
        } 

        /// <summary>
        /// The name of the value type that will be generated to hold the incremental results of the operation.
        /// </summary>
        /// <remarks>The type is generated only if the callback has more than one parameter, 
        /// not including the progress percentage and the task ID, if present.</remarks>
        public string ResultsTypeName
        {
            get { return resultsTypeName; }
            set { resultsTypeName = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="Boolean"/> value that determines whether the progress event should be raised synchronously or asynchronously.
        /// </summary>
        /// <value><c>true</c> (the default) to raise the event asynchronously (i.e. the server does not wait for the event handler to return), <c>false</c> to raise it synchronously.s</value>
        /// <remarks>If the method returns a cancellation indication (designated by the <see cref="CancelFlagAttribute"/>), the event must be raised synchronously.</remarks>
        public bool Async
        {
            get { return async; }
            set { async = value; }
        }

        #endregion

        #region Private Fields

        private readonly string eventName;
        private string resultsTypeName;
        private bool async = true;

        #endregion
    }
}

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
Web02 | 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