Пример #1
0
        internal void FlushPostedProperties()
        {
            RequiresNotDisposed();
            if (postedProperties.Count == 0 || !scheduler.CanEnterTimedDelegate())
            {
                return;
            }
            TelemetryEvent    telemetryEvent = CreateTelemetryEvent("PostProperty");
            PostPropertyEntry result;

            while (postedProperties.TryDequeue(out result))
            {
                if (result.IsReserved)
                {
                    telemetryEvent.ReservedProperties[result.Key] = result.Value;
                }
                else
                {
                    telemetryEvent.Properties[result.Key] = result.Value;
                }
            }
            TelemetrySession.ValidateEvent(telemetryEvent);
            ValidateEventProperties(telemetryEvent);
            AddReservedPropertiesToTheEvent(telemetryEvent);
            hostSession.PostValidatedEvent(telemetryEvent);
            scheduler.ExitTimedDelegate();
        }
Пример #2
0
 /// <summary>
 /// Process events from the queue.
 /// Process all events.
 /// </summary>
 public void ProcessEvents()
 {
     try
     {
         if (base.IsDisposed)
         {
             throw new ObjectDisposedException(GetType().Name, "it is not allowed to process events after channel is disposed");
         }
         if (scheduler.CanEnterTimedDelegate())
         {
             TelemetryEvent result;
             while (queue.TryDequeue(out result))
             {
                 eventProcessor.ProcessEvent(result);
             }
             if (!hasProcessedEvents)
             {
                 hasProcessedEvents = true;
                 initializedAction();
             }
         }
     }
     catch (Exception exceptionObject)
     {
         FaultEvent faultEvent = new FaultEvent("VS/Telemetry/InternalFault", $"Exception in SessionChannel.EventProcessorChannel ProcessEvents Channel = {ChannelId}", exceptionObject)
         {
             PostThisEventToTelemetry = false
         };
         faultEvent.AddProcessDump(Process.GetCurrentProcess().Id);
         telemetrySession.PostEvent(faultEvent);
     }
     finally
     {
         scheduler.ExitTimedDelegate();
     }
 }