private OnGoingStudy StartStudy(TwitterStudy study) { var reportData = new TwitterSpyStudyData(study); Trace.WriteLine(string.Format("Study {0} started", study.Id)); foreach (var topic in study.Topics) { _stream.AddTrack(topic, reportData.ProcessTweet); } var onGoingStudy = new OnGoingStudy { Data = reportData }; // the object is stored so that the timer isn't garbage collected var timer = new Timer(o => { var data = (TwitterSpyStudyData)o; // // Remove the study from the ongoing list // lock (_onGoingStudies) { _onGoingStudies.Remove(onGoingStudy); } CheckIfStreamNeedsToBeStopped(); // // Remove topics // foreach (var topic in data.Study.Topics) { _stream.RemoveTrack(topic); } var report = data.GetReport(); // // send report to the client via queue // _reportQueue.AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(report))); }, reportData, study.Duration, TimeSpan.FromTicks(-1)); onGoingStudy.Timer = timer; return(onGoingStudy); }
private async Task LoadEmployeeData() { StartOperation("Getting employee studies"); Studies = new TwitterStudy[0]; try { Studies = await _service.GetPendingStudiesAsync(EmployeeId); } catch (Exception e) { } StopOperation(); }
public TwitterSpyStudyData(TwitterStudy study) { Study = study; Histogram = new Dictionary <string, int>(); Authors = new HashSet <string>(); }