/// <summary> /// Create a new HTTP event source. /// </summary> /// <param name="EventIdentification">The internal identification of the HTTP event.</param> public HTTPEventSource(String EventIdentification) { if (EventIdentification == null || EventIdentification == "") throw new ArgumentNullException("The EventIdentification must not be null or zero!"); this.EventIdentification = EventIdentification; this.ListOfEvents = new TSQueue<HTTPEvent>(); }
public DigibyteMiner() { MiningQueue = new TSQueue <IMinerProgram>(); DownloadingQueue = new TSQueue <IMinerProgram>(); RunningMiners = new TSList <IMinerProgram>(); MiningCommand = MinerProgramCommand.Stop; m_minerThread = new Thread(new ParameterizedThreadStart(MiningThread)); m_downloadingThread = new Thread(new ParameterizedThreadStart(DownLoadingThread)); InitiateThreads(); }
public void InitializeView() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DownloadRequestQueue = new TSQueue <DownloadRequest>(); m_Timer = new System.Windows.Forms.Timer(); RegisterForTimer(ExecuteDownloadRequests); m_Timer.Interval = 10000; #if DEBUG m_Timer.Interval = 10000; #endif m_Timer.Tick += t_Tick; }
public ChannelQueue(TTLChannel channel_, TSQueue<float> queue_) { channel = channel_; queue = queue_; return; }
TSQueue<float> AddChannel(Channel channel) { lock(dictionary) { //Check if channel is already in use if(dictionary.ContainsKey(channel)) throw new Exception(String.Format("Session already uses {0}", channel.ToString()[0])); //!!Possible bug TTLChannel ttlChannel = GetChannel(encoder, channel); TSQueue<float> queue = new TSQueue<float>(); dictionary.Add(channel, new ChannelQueue(ttlChannel, queue)); return queue; } }
/// <summary> /// Create a new HTTP event source. /// </summary> /// <param name="EventIdentification">The internal identification of the HTTP event.</param> /// <param name="MaxNumberOfCachedEvents">Maximum number of cached events.</param> /// <param name="RetryIntervall">The retry intervall.</param> /// <param name="LogfileName">A delegate to create a filename for storing and reloading events.</param> public HTTPEventSource(String EventIdentification, UInt64 MaxNumberOfCachedEvents = 500, TimeSpan?RetryIntervall = null, Func <String, DateTime, String> LogfileName = null) { #region Initial checks EventIdentification.FailIfNullOrEmpty("The HTTP Server Sent Event must have a name!"); #endregion this.EventIdentification = EventIdentification; this.QueueOfEvents = new TSQueue <HTTPEvent>(MaxNumberOfCachedEvents); this.MaxNumberOfCachedEvents = MaxNumberOfCachedEvents; this.RetryIntervall = RetryIntervall.HasValue ? RetryIntervall.Value : TimeSpan.FromSeconds(30); this.LogfileName = LogfileName; this.IdCounter = 0; #region Setup Logfile(s) if (LogfileName != null) { Int64 CurrentCounter; foreach (var logfilename in Directory.EnumerateFiles(Directory.GetCurrentDirectory(), this.EventIdentification + "*.log", SearchOption.TopDirectoryOnly)) { File.ReadLines(logfilename). Take((Int64)MaxNumberOfCachedEvents - (Int64)QueueOfEvents.Count). Select(line => line.Split((Char)0x1E)). ForEach(line => { try { CurrentCounter = Int64.Parse(line[0]); if (IdCounter < CurrentCounter) { IdCounter = CurrentCounter; } QueueOfEvents.Push( new HTTPEvent((UInt64)CurrentCounter, DateTime.Parse(line[1]), line[2], line[3].Split((Char)0x1F))); } #pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. catch (Exception) #pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { } }); if (QueueOfEvents.Count >= MaxNumberOfCachedEvents) { break; } } QueueOfEvents.OnAdded += (Sender, Value) => { using (var logfile = File.AppendText(this.LogfileName(this.EventIdentification, DateTime.Now))) { logfile.WriteLine(String.Concat(Value.Id, (Char)0x1E, Value.Timestamp.ToIso8601(), (Char)0x1E, Value.Subevent, (Char)0x1E, Value.Data.AggregateWith((Char)0x1F))); } }; } #endregion }