protected virtual void OnUserActivitySampleReady(UserActivitySampleEventArgs e)
 {
     if (UserActivitySampleReady != null)
     {
         UserActivitySampleReady(this, e);
     }
 }
示例#2
0
        void OnUserActivitySampleReady(object sender, UserActivitySampleEventArgs e)
        {
            // take the stats we just got and stick them in the database
            // for whatever the current time segment is

            // This is going to need some exception handling
            TimeSlice timeSlice = GetTimeSliceFromUserActivitySample(e.ProcessActivity);

            // TODO:
            // This will fail (won't it?) when there's already data recorded for this time segment
            // which should be possible to get when starting up multiple times? maybe? possibly not?
            // because we'd be triggered in 5 minutes time, so that should be a different segment?
            this.dataContext.TimeSlices.Add(timeSlice);
            this.dataContext.Commit();

            // TODO
            // fire an event off saying we've just saved some new data to the database
            // sending out the TimeSegment along with it.
            // the UI can listen for that.
        }
        private void OnActivitySampleTimer(object info)
        {
            // grab stats from processactivitysampler and fire off the event
            var currentSegment = processActivitySampler.StartNewTimeSegment();

            var eventData = new UserActivitySampleEventArgs(currentSegment);

            OnUserActivitySampleReady(eventData);
        }