If the NetworkCommunicator exists only once per application, you should create a singelton. When required, I can provid you a codeCode sample:
/// <summary>
/// Provides a base class for singeltons.
/// </summary>
/// <typeparam name="T">The class that act as a singelton.</typeparam>
public abstract class Singleton<T>
where T : class
{
protected Singleton()
{
}
/// <summary>
/// Gets the singelton instance.
/// </summary>
public static T Instance
{
get { return Nested._instance; }
}
private sealed class Nested
{
/// <summary>
/// Creates the nested instance class.
/// </summary>
///
/// <remarks>
/// Explicit static constructor to tell the compiler
// not to mark type as beforefieldinit.
/// </remarks>
static Nested()
{
ConstructorInfo constructor = typeof (T).GetConstructor(Type.EmptyTypes) ??
typeof(T).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);
if (constructor == null)
throw new InvalidOperationException("Class has no private nor public constructor");
_instance = (T)constructor.Invoke(null);
}
internal static readonly T _instance;
}
}
If someone has any suggestion about my singelton implementation, let me know it..