/// <summary>
        /// Creates an async thread but does not start the thread
        /// </summary>
        /// <returns>
        /// The async thread.
        /// </returns>
        public static Thread GetOrCreateAsyncThread(Type[] artefactTypes, bool useOutput = true)
        {
            TextWriter output, error;
            if (useOutput)
            {
                output = Console.Out;
                error = Console.Error;
            }
            else
                output = error = TextWriter.Null;

            if (_serviceHostThread != null && _serviceHostThread.IsAlive)
                return _serviceHostThread;

            _exitServiceHost = false;
            return _serviceHostThread = new Thread(() =>
            {
                ArtefactServiceHost sh = null;
                try
                {
                    sh = new ArtefactServiceHost();
                    sh.Open();
                    while (!_exitServiceHost)
                        Thread.Sleep(255);
                }
                catch (Exception ex)
                {
                    error.WriteLine("\nServiceHost Exception (State={0}):\n{1}\n", (sh == null ? "(null)" : sh.State.ToString()), ex.ToString());
                }
                finally
                {
                    if (sh != null && sh.State != CommunicationState.Closed && sh.State != CommunicationState.Closing)
                        sh.Close();
                }
            });
        }
 /// <summary>
 /// The entry point of the program when output as an .exe
 /// </summary>
 /// <param name='args'>
 /// The command-line arguments.
 /// </param>
 public static void Main(string[] args)
 {
     ArtefactServiceHost sh = null;
     try
     {
         sh = new ArtefactServiceHost();
         sh.Open();
         Console.ReadKey();
     }
     catch (/*Communication*/Exception ex)
     {
         Console.Error.WriteLine("\nServiceHost Exception (State=" + (sh == null ? "(null)" : sh.State.ToString()) + "):\n" + ex.ToString() + "\n");
     }
     finally
     {
         if (sh != null && sh.State != CommunicationState.Closed && sh.State != CommunicationState.Closing)
             sh.Close();
     }
 }