private static void CloseLogSingleton(object sender, EventArgs e)
 {
     if (GccProtocolActivityLoggerSingleton.instance != null)
     {
         GccProtocolActivityLogger gccProtocolActivityLogger = Interlocked.Exchange <GccProtocolActivityLogger>(ref GccProtocolActivityLoggerSingleton.instance, null);
         GccProtocolActivityLoggerSingleton.creationNotMyJob = 0;
         gccProtocolActivityLogger.Close();
     }
 }
        public static GccProtocolActivityLogger Get(string clientInfoString)
        {
            string protocolName = GccProtocolActivityLoggerSingleton.GetProtocolName(clientInfoString);

            if (!GccProtocolActivityLoggerSingleton.DoWeNeedToLog(protocolName))
            {
                return(null);
            }
            if (Interlocked.Exchange(ref GccProtocolActivityLoggerSingleton.creationNotMyJob, 1) == 0)
            {
                GccProtocolActivityLogger gccProtocolActivityLogger = new GccProtocolActivityLogger(protocolName);
                gccProtocolActivityLogger.Initialize();
                AppDomain.CurrentDomain.DomainUnload       += GccProtocolActivityLoggerSingleton.CloseLogSingleton;
                GccProtocolActivityLoggerSingleton.instance = gccProtocolActivityLogger;
                GccProtocolActivityLoggerSingleton.busyCreating.Set();
            }
            else if (GccProtocolActivityLoggerSingleton.instance == null)
            {
                GccProtocolActivityLoggerSingleton.busyCreating.WaitOne();
            }
            return(GccProtocolActivityLoggerSingleton.instance);
        }