Click here to Skip to main content
15,892,746 members
Articles / Programming Languages / C#

Prism Event Aggregator Service and Extension Methods

Rate me:
Please Sign up or sign in to vote.
4.50/5 (12 votes)
24 Mar 2009CPOL5 min read 105.2K   932   23  
The extremely easy way to connect your code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Events;

namespace GenericEventAggregator
{
    public static class ServicesFactory
    {
        // Singleton instance of the EventAggregator service
        private static EventAggregator eventSerice = null;

        // Lock (sync) object
        private static object _syncRoot = new object();

        // Factory method
        public static EventAggregator EventService
        {
            get
            {
                // Lock execution thread in case of multi-threaded
                // (concurrent) access.
                lock (_syncRoot)
                {
                    if (null == eventSerice)
                    {
                        eventSerice = new EventAggregator();
                    }
                    // Return singleton instance
                    return eventSerice;
                } // lock
            }
        }
    }
}

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)


Written By
Software Developer (Senior) Free lancer
Israel Israel
I'm very interested on .Net related technologies (WPF,WCF,WF,Data services, Silverlight ...) and software Architecture issues.

Comments and Discussions