Exemple #1
0
        private static void WriteToFileQueue(object source, ElapsedEventArgs e, bool shuttingDown = false)
        {
            if (!shuttingDown)
            {
                ChangeFileName();
            }
            ChangeFileNameWaitHandle.WaitOne(); // wait when the file name is being changed
            var bufferedData = new RoomInfoWrapper[JsonDataQueue.Count];

            lock (JsonDataQueue)
            {
                JsonDataQueue.CopyTo(bufferedData, 0);
                JsonDataQueue.Clear();
            }

            var utf8Text = JsonConvert.SerializeObject(bufferedData);
            var byteText = Encoding.ASCII.GetBytes(utf8Text);

            var b = SevenZipHelper.Compress(byteText);

            _sw.Write(Encoding.UTF8.GetString(b));

            /*Console.WriteLine(
             * Encoding.ASCII.GetString(
             *  SevenZipHelper.Decompress(
             *      b)).Substring(0,400));*/
        }
 public void CopyTo(ILogMessage[] array, int arrayIndex)
 {
     lock (syncObj)
     {
         try
         {
             messageCollection.CopyTo(array, arrayIndex);
         }
         catch (ObjectDisposedException e)
         {
             //This means somehow another thread disposed of the collection before a call to CopyTo
             //We do nothing right now though. We rethrow with more information.
             throw new Exception("Exception of type: " + typeof(ObjectDisposedException).ToString() + " occured in " + "CopyTo() method in " + this.GetType().ToString() + ". Object was already disposed.");
         }
     }
 }
Exemple #3
0
 public void CopyTo(T[] array, int index)
 {
     _collection.CopyTo(array, index);
 }