Beispiel #1
0
        private ProfilerResult(ProcedureContext procedureContext, CollectorsSynchronizer synchronizer)
        {
            _procedureContext = procedureContext;
            _synchronizer     = synchronizer;

            _bulkCopy = new ProfilerBulkCopyDataReader(_procedureContext);
        }
Beispiel #2
0
 public void Init()
 {
     if (cvNewOsteotomyBaseConsoleView != null)
     {
         ProcedureContext pcx = DocSession.ProcedureContexts[DocumentSession.Layout.Planning.ToString()];
         cvNewOsteotomyBaseConsoleView.Init(pcx);
     }
 }
Beispiel #3
0
        private static AnalyzerTaskResult InternalAnalyzeAsync(ProcedureContext procedureContext, AdomdClient.AdomdConnection connection)
        {
            var queryResult       = default(DataTable);
            var profilerResult    = default(ProfilerResult);
            var performanceResult = default(PerformanceResult);

            using (var collectorsSynchronizer = CollectorsSynchronizer.Create(procedureContext.CancellationToken))
                using (var performanceTask = PerformanceCollector.StartAsync(procedureContext, collectorsSynchronizer))
                {
                    try
                    {
                        if (!performanceTask.IsFaulted && !procedureContext.IsCancellationRequested)
                        {
                            #region profiler collector

                            using (var profilerCancellation = CancellationTokenSource.CreateLinkedTokenSource(procedureContext.CancellationToken))
                                using (var profilerTask = ProfilerCollector.StartAsync(procedureContext, collectorsSynchronizer, profilerCancellation.Token))
                                {
                                    try
                                    {
                                        if (!profilerTask.IsFaulted && !profilerCancellation.IsCancellationRequested)
                                        {
                                            try
                                            {
                                                queryResult = AdomdClientHelper.ExecuteDataTable(
                                                    connection,
                                                    procedureContext.CancellationToken,
                                                    procedureContext.Statement,
                                                    activityID: procedureContext.ClientActivityID,
                                                    rowsLimit: procedureContext.QueryResultRowLimit,
                                                    beforeStart: () => EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeStepExecuteStatement),
                                                    beforeWait: () => EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeStepPendingOutcome)
                                                    );
                                            }
                                            finally
                                            {
                                                profilerCancellation.Cancel();
                                            }
                                        }
                                    }
                                    finally
                                    {
                                        profilerResult = profilerTask.Result;
                                    }
                                }

                            #endregion
                        }
                    }
                    finally
                    {
                        performanceResult = performanceTask.Result;
                    }
                }

            return(AnalyzerTaskResult.Create(queryResult, profilerResult, performanceResult));
        }
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <example>
 /// call ASQA.Reconfigure("<config />");
 /// </example>
 public static void Reconfigure(string xconfig)
 {
     using (ProcedureMutex.TryAcquire())
     {
         EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureReconfigureBegin);
         ProcedureContext.Reconfigure(xconfig);
         EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureReconfigureEnd);
     }
 }
Beispiel #5
0
        public static DataSet Analyze(string statement, int clearCacheMode, int queryResultRowLimit, string clientVersion, string clientType)
        {
            using (ProcedureMutex.TryAcquire())
            {
                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeBegin);

                DataSet procedureResult;
                using (var procedureContext = ProcedureContext.CreateForLiveExecution(statement, (ClearCacheMode)clearCacheMode, queryResultRowLimit, clientVersion, clientType))
                    using (var analyzeResult = new AnalyzerResult(procedureContext))
                    {
                        if (AdomdServer.Context.ExecuteForPrepare)
                        {
                            procedureResult = analyzeResult.CalculateForPrepare();
                        }
                        else
                        {
                            procedureContext.ValidateStatement();
                            procedureContext.ClearCache();
                            procedureContext.LoadCubeScript();

                            AdomdServer.Context.CheckCancelled();

                            using (var analyzeTask = AnalyzerTask.StartAsync(procedureContext))
                            {
                                #region Pending outcome

                                while (!analyzeTask.Wait(100))
                                {
                                    try
                                    {
                                        AdomdServer.Context.CheckCancelled();
                                    }
                                    catch (AdomdServer.AdomdException)
                                    {
                                        procedureContext.Cancel();

                                        while (!analyzeTask.IsCompleted)
                                        {
                                            Thread.Sleep(50);
                                        }

                                        throw;
                                    }
                                }

                                #endregion

                                procedureResult = analyzeResult.Calculate(analyzeTask.Result);
                            }
                        }
                    }

                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeEnd);
                return(procedureResult);
            }
        }
Beispiel #6
0
        public static Task <PerformanceResult> StartAsync(ProcedureContext procedureContext, CollectorsSynchronizer collectorsSynchronizer)
        {
            #region Argument exceptions

            if (collectorsSynchronizer == null)
            {
                throw new ArgumentNullException("collectorsSynchronizer");
            }
            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            var started = new ManualResetEvent(false);
            var faulted = new ManualResetEvent(false);

            var performanceTask = new Task <PerformanceResult>(() =>
            {
                var performanceResult = PerformanceResult.Create(procedureContext);

                started.Set();

                while (!collectorsSynchronizer.IsCompleted)
                {
                    try
                    {
                        DateTime eventTime;
                        if (collectorsSynchronizer.TryTake(out eventTime, Timeout.Infinite, procedureContext.CancellationToken))
                        {
                            performanceResult.Collect(eventTime);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        break;
                    }
                }

                if (procedureContext.ExecutionMode == ProcedureExecutionMode.Batch)
                {
                    performanceResult.FlushBatch(ThreadingTimeout.Infinite).Wait();
                }

                return(performanceResult);
            },
                                                               procedureContext.CancellationToken, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);

            performanceTask.ContinueWith((previousTask) => faulted.Set(), TaskContinuationOptions.AttachedToParent | TaskContinuationOptions.OnlyOnFaulted);
            performanceTask.Start();

            WaitHandle.WaitAny(new[] { started, faulted });

            return(performanceTask);
        }
 private void InitializeContext()
 {
     context = new ProcedureContext();
     context.ConfigurationFactory = new FeatureConfigurationFactory(new ModuleLogger(logger, nameof(FeatureConfigurationFactory)));
     context.CreateBackup         = CreateBackup;
     context.Logger   = logger;
     context.MainMenu = BuildMainMenu(context);
     context.Update   = new SystemConfigurationUpdate(new ModuleLogger(logger, nameof(SystemConfigurationUpdate)));
     context.UserInfo = new UserInfo(new ModuleLogger(logger, nameof(UserInfo)));
 }
Beispiel #8
0
 /// <summary>
 ///
 /// </summary>
 /// <example>call ASQA.GetConfiguration(configurationType);</example>
 public static DataTable GetConfiguration(int configurationType)
 {
     using (ProcedureMutex.TryAcquire())
     {
         EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureGetConfigurationBegin);
         var configuration = ProcedureContext.GetConfigurationFor((ConfigurationType)configurationType);
         EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureGetConfigurationEnd);
         return(configuration);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Creates na new <see cref="ProcedureContext"/> object used to schedule remote procedure call.
        /// </summary>
        /// <param name="message">Call message used for RPC request</param>
        /// <param name="definition">Definition of procedure to be called</param>
        /// <param name="session">WAMP message sender session object</param>
        /// <returns></returns>
        public virtual ProcedureContext CreateProcedureContext(CallMessage message, ProcedureDefinition definition, IWampSession session)
        {
            var procedureContext = new ProcedureContext
            {
                Arguments           = message.Arguments,
                CallId              = message.CallId,
                ProcedureDefinition = definition,
                RequesterSession    = session
            };

            return(procedureContext);
        }
        public AnalyzerResult(ProcedureContext procedureContext)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            _procedureContext = procedureContext;
        }
Beispiel #11
0
        public static IList <PerformanceCounter> ActivePerformanceCounters(ProcedureContext procedureContext)
        {
            #region Argument exception

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            var activePerformanceCounters = DefaultPerformanceCounters(procedureContext.SSASInstanceName, procedureContext.SSASInstanceVersion);

            Action action = () =>
            {
                var configurationFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ProcedureContext.ConfigurationFileRelativePath);

                if (File.Exists(configurationFile))
                {
                    var configuredPerformanceCounters = XDocument.Load(configurationFile).Root
                                                        .Elements(ProcedureConfiguration.XConfigPerformanceCollection)
                                                        .Descendants(ProcedureConfiguration.XConfigPerformanceItem)
                                                        .Select((e) => new
                    {
                        CategoryName = e.Attribute(ProcedureConfiguration.XConfigPerformanceAttributeCategory).Value,
                        CounterName  = e.Attribute(ProcedureConfiguration.XConfigPerformanceAttributeName).Value,
                    });

                    foreach (var counter in configuredPerformanceCounters)
                    {
                        if (!activePerformanceCounters.Any((c) => c.CategoryName == counter.CategoryName && c.CounterName == counter.CounterName))
                        {
                            activePerformanceCounters.Add(new PerformanceCounter(counter.CategoryName, counter.CounterName));
                        }
                    }
                }
            };

            using (var task = Task.Factory.StartNew(action))
                task.Wait();

            foreach (var counter in activePerformanceCounters)
            {
                counter.NextValue();
            }

            return(activePerformanceCounters);
        }
Beispiel #12
0
        public static ProfilerResult CreateForPrepare(ProcedureContext procedureContext)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            return(new ProfilerResult(procedureContext, synchronizer: null)
            {
                ExecuteForPrepare = true
            });
        }
        public static AnalyzerTaskResult CreateForPrepare(ProcedureContext procedureContext)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            return(new AnalyzerTaskResult()
            {
                Performance = PerformanceResult.CreateForPrepare(procedureContext),
                Profiler = ProfilerResult.CreateForPrepare(procedureContext),
                QueryResult = default(DataTable)
            });
        }
Beispiel #14
0
        public static ProfilerResult Create(ProcedureContext procedureContext, CollectorsSynchronizer synchronizer)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            if (synchronizer == null)
            {
                throw new ArgumentNullException("synchronizer");
            }

            #endregion

            return(new ProfilerResult(procedureContext, synchronizer));
        }
        public static string GetTraceDefinitionText()
        {
            var info    = ProcedureContext.GetServerInfo();
            var version = info.Item1;

            Func <string> read = () =>
            {
                string path;
                using (var process = Process.GetCurrentProcess())
                    path = Path.GetDirectoryName(process.MainModule.FileName);

                path = Path.Combine(path, "Resources", "1033", "tracedefinition{0}{1}.xml".FormatWith(version.Major, version.Minor));

                return(File.ReadAllText(path));
            };

            using (var task = Task.Factory.StartNew(read))
                return(task.Result);
        }
 private IList <MainMenuOption> BuildMainMenu(ProcedureContext context)
 {
     return(new List <MainMenuOption>
     {
         new MainMenuOption {
             IsSelected = true, NextStep = new Restore(context), Result = ProcedureStepResult.Continue, Text = "Restore system configuration via backup mechanism"
         },
         new MainMenuOption {
             NextStep = new Reset(context), Result = ProcedureStepResult.Continue, Text = "Reset system configuration to default values"
         },
         new MainMenuOption {
             NextStep = new Procedure.Version(context), Result = ProcedureStepResult.Continue, Text = "Show version information"
         },
         new MainMenuOption {
             NextStep = new Log(context), Result = ProcedureStepResult.Continue, Text = "Show application log"
         },
         new MainMenuOption {
             Result = ProcedureStepResult.Terminate, Text = "Exit"
         }
     });
 }
Beispiel #17
0
        public static Task <AnalyzerTaskResult> StartAsync(ProcedureContext procedureContext)
        {
            #region Argument exception

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            #endregion

            EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeStepStartAnalyzerTask);

            return(Task.Factory.StartNew(() =>
            {
                using (var connection = procedureContext.GetAnalyzeConnection())
                    return InternalAnalyzeAsync(procedureContext, connection);
            },
                                         procedureContext.CancellationToken,
                                         TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning,
                                         TaskScheduler.Default));
        }
Beispiel #18
0
        private PerformanceResult(ProcedureContext procedureContext, IEnumerable <PerformanceCounter> counters)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }

            if (counters == null)
            {
                throw new ArgumentNullException("counters");
            }

            #endregion

            _procedureContext = procedureContext;

            foreach (var item in counters)
            {
                _performances.Add(PerformanceAggregate.Create(item));
            }
        }
Beispiel #19
0
 /// <summary>
 /// Pushes a new procedure context.
 /// </summary>
 public void PushProcedureContext()
 {
     Contract.Ensures(HasProcedureContext);
       procedureContext = new ProcedureContext(procedureContext);
 }
Beispiel #20
0
 /// <summary>
 /// Requires there to be a procedure context.  Pops it.
 /// </summary>
 public void PopProcedureContext()
 {
     Contract.Requires(HasProcedureContext);
       Contract.Assert(procedureContext != null);  // follows from precondition
       procedureContext = procedureContext.Next;
 }
Beispiel #21
0
 public ProfilerBulkCopyDataReader(ProcedureContext procedureContext)
 {
     _procedureContext = procedureContext;
 }
Beispiel #22
0
 public override void Suspend()
 {
     ProcedureContext.OnViewComponentChange(new ViewComponentChangeArgs(ViewComponents.CloseCC, 0));
     Session.CurrentContext.ProcedureBegin -= ProcBegin;
     base.Suspend();
 }
Beispiel #23
0
        public override void Activate()
        {
            base.Activate();

            // Save original body side
            mPatientBodySide = Session.PatientBodySide;

            if (!InitManually)
            {
                IEnumerable <ManualMeasurementItem> measurements = null;

                var helper = new WizardMeasurementsHelper();

                if (Parameter is string)
                {
                    var wizard = helper.GetWizard((string)Parameter);

                    if (wizard != null)
                    {
                        measurements = wizard.SelectedMeasurements;
                        mSkipMeasurementIfCompleted = wizard.Skip;
                    }
                }
                else if (Parameter is IEnumerable <ManualMeasurementItem> )
                {
                    measurements = Parameter as IEnumerable <ManualMeasurementItem>;

                    mSkipMeasurementIfCompleted = (helper.GetWizard(measurements.FirstOrDefault()?.WizardName)?.Skip).GetValueOrDefault(false);
                }

                if (ValidateMeasurementsList(measurements))
                {
                    // Init Wizard View
                    if (mWizardView == null && ProcedureContext.AllViews.TryGetValue("Wizard", out ViewRegistrar viewRegistrar))
                    {
                        var parameter = new object[] { };
                        mWizardView = DynamicInitializer.New <IWizardView>(viewRegistrar.ViewType, parameter);
                        mWizardView.Init(this, Session);
                        mWizardView.Position            = DockSide.Left;
                        mWizardView.PositionInContainer = DockContainerSide.Center;
                        DockItems = new List <IDockItem>
                        {
                            mWizardView
                        };
                    }

                    ProcedureContext.OnViewComponentChange(new ViewComponentChangeArgs(ViewComponents.OpenCC, 0));

                    // Select first procedure
                    if (NextProcedure())
                    {
                        Session.CurrentContext.ProcedureBegin -= ProcBegin;
                        Session.CurrentContext.ProcedureBegin += ProcBegin;

                        mbCanClose = false;

                        return;
                    }
                }

                Close();
            }
        }
Beispiel #24
0
        public override SyntaxNode Generate(Context context)
        {
            var name      = this.Fields.Get("NAME").CreateValidName();
            var statement = this.Statements.FirstOrDefault(x => x.Name == "STACK");

            if (string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }

            // if the statement is missing, create a stub one
            if (null == statement)
            {
                statement = new Statement
                {
                    Block = null,
                    Name  = "STACK"
                };
            }

            ReturnStatementSyntax returnStatement = null;

            // tack the return value on as a block at the end of the statement
            if (this.Values.Any(x => x.Name == "RETURN"))
            {
                var returnValue      = this.Values.First(x => x.Name == "RETURN");
                var returnExpression = returnValue.Generate(context) as ExpressionSyntax;
                if (returnExpression == null)
                {
                    throw new ApplicationException($"Unknown expression for return statement.");
                }

                returnStatement = ReturnStatement(returnExpression);
            }

            var parameters = new List <ParameterSyntax>();

            var procedureContext = new ProcedureContext()
            {
                Parent = context
            };

            foreach (var mutation in this.Mutations.Where(x => x.Domain == "arg" && x.Name == "name"))
            {
                string parameterName = mutation.Value.CreateValidName();

                ParameterSyntax parameter = Parameter(
                    Identifier(parameterName)
                    )
                                            .WithType(
                    IdentifierName("dynamic")
                    );

                parameters.Add(parameter);
                procedureContext.Parameters[parameterName] = parameter;
            }

            if (statement?.Block != null)
            {
                var statementSyntax = statement.Block.GenerateStatement(procedureContext);
                if (statementSyntax != null)
                {
                    procedureContext.Statements.Add(statementSyntax);
                }
            }

            if (returnStatement != null)
            {
                procedureContext.Statements.Add(returnStatement);
            }

            LocalFunctionStatementSyntax methodDeclaration = null;

            var returnType = (returnStatement == null) ? PredefinedType(Token(SyntaxKind.VoidKeyword)) : (TypeSyntax)IdentifierName("dynamic");

            methodDeclaration =
                LocalFunctionStatement(
                    returnType,
                    Identifier(name)
                    )
                .WithBody(
                    Block(procedureContext.Statements)
                    );

            if (parameters.Any())
            {
                var syntaxList = SeparatedList(parameters);

                methodDeclaration =
                    methodDeclaration
                    .WithParameterList(
                        ParameterList(syntaxList)
                        );
            }

            context.Functions[name] = methodDeclaration;

            return(base.Generate(context));
        }
 /// <summary>
 /// Pushes a new procedure context.
 /// </summary>
 public void PushProcedureContext()
 {
     Contract.Ensures(HasProcedureContext);
     procedureContext = new ProcedureContext(procedureContext);
 }
Beispiel #26
0
 public ProcedureContext(ProcedureContext next)
 {
     Blocks = new Hashtable /*string->Block!*/ ();
     Next = next;
 }
Beispiel #27
0
        public static DataSet AnalyzeBatch(string statement, int clearCacheMode, string batchID, string batchConnectionString, string clientVersion, string clientType, string batchName, bool throwOnError)
        {
            using (ProcedureMutex.TryAcquire())
            {
                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeBegin);

                var procedureResult = new DataSet();
                using (var procedureContext = ProcedureContext.CreateForBatchExecution(statement, (ClearCacheMode)clearCacheMode, batchID, batchConnectionString, clientVersion, clientType, batchName))
                    using (var analyzeResult = new AnalyzerResult(procedureContext))
                    {
                        AdomdServer.Context.CheckCancelled();

                        BatchHelper.Initialize(procedureContext);
                        try
                        {
                            procedureContext.ValidateStatement();
                            procedureContext.ClearCache();
                            procedureContext.LoadCubeScript();

                            AdomdServer.Context.CheckCancelled();

                            using (var analyzeTask = AnalyzerTask.StartAsync(procedureContext))
                            {
                                #region Pending outcome

                                while (!analyzeTask.Wait(100))
                                {
                                    try
                                    {
                                        AdomdServer.Context.CheckCancelled();
                                    }
                                    catch (AdomdServer.AdomdException)
                                    {
                                        procedureContext.Cancel();

                                        while (!analyzeTask.IsCompleted)
                                        {
                                            Thread.Sleep(50);
                                        }

                                        throw;
                                    }
                                }

                                #endregion

                                procedureResult = analyzeResult.Calculate(analyzeTask.Result);
                            }

                            BatchHelper.Finalize(procedureContext);
                        }
                        catch (Exception ex)
                        {
                            BatchHelper.TraceException(procedureContext, ex);

                            if (throwOnError)
                            {
                                throw ex;
                            }
                        }
                    }

                EventsNotifier.Instance.Notify(ProcedureEvents.ProcedureAnalyzeEnd);
                return(procedureResult);
            }
        }
Beispiel #28
0
 public ProcedureContext(ProcedureContext next)
 {
     Blocks = new Hashtable/*string->Block!*/ ();
     Next   = next;
 }
Beispiel #29
0
 /// <summary>
 ///
 /// </summary>
 /// <example>call ASQA.GetVersion();</example>
 public static DataTable GetVersion()
 {
     return(ProcedureContext.GetAsqaServerVersion().ToVersionTable());
 }
 public ProcedureContext(ProcedureContext next)
 {
     Blocks = new Dictionary <string, Block>();
     Next   = next;
 }
        public static Task <ProfilerResult> StartAsync(ProcedureContext procedureContext, CollectorsSynchronizer collectorsSynchronizer, CancellationToken cancellationToken)
        {
            #region Argument exceptions

            if (procedureContext == null)
            {
                throw new ArgumentNullException("procedureContext");
            }
            if (collectorsSynchronizer == null)
            {
                throw new ArgumentNullException("collectorsSynchronizer");
            }
            if (cancellationToken == null)
            {
                throw new ArgumentNullException("cancellationToken");
            }

            #endregion

            var started = new ManualResetEvent(false);
            var faulted = new ManualResetEvent(false);

            var traceTask = new Task <ProfilerResult>(() =>
            {
                #region task

                var profilerResult = ProfilerResult.Create(procedureContext, collectorsSynchronizer);

                using (var server = new Server())
                {
                    server.Connect(procedureContext.ConnectionString);

                    var trace = server.Traces.Find(ProfilerCollector.TraceId);
                    if (trace == null)
                    {
                        throw new ApplicationException("Trace not found [{0}]".FormatWith(ProfilerCollector.TraceName));
                    }

                    var onTraceEventException = default(Exception);
#if ASQASSAS13 || ASQASSAS14
                    var clientActivityID = procedureContext.ClientActivityID.ToString("D");
#endif
                    trace.OnEvent += (s, e) =>
                    {
                        #region OnEvent

                        try
                        {
#if ASQASSAS11 || ASQASSAS12
                            var found = e.ConnectionID == procedureContext.CurrentConnectionID;
#else
                            var found = clientActivityID.Equals(e[TraceColumn.ActivityID], StringComparison.OrdinalIgnoreCase);
#endif
                            if (found)
                            {
                                profilerResult.Add(e);
                            }
                        }
                        catch (Exception ex)
                        {
                            if (onTraceEventException == null)
                            {
                                onTraceEventException = ex;
                            }

                            profilerResult.CollectCompleted.Set();
                        }

                        #endregion
                    };

                    trace.Start();

                    while (!trace.IsStarted)
                    {
                        Thread.Sleep(50);
                    }
                    started.Set();

                    cancellationToken.WaitHandle.WaitOne(Timeout.Infinite);

                    WaitHandle.WaitAny(new []
                    {
                        profilerResult.CollectCompleted,
                        procedureContext.CancellationToken.WaitHandle
                    });

                    if (onTraceEventException != null)
                    {
                        throw onTraceEventException;
                    }

                    if (procedureContext.ExecutionMode == ProcedureExecutionMode.Batch && !procedureContext.IsCancellationRequested)
                    {
                        profilerResult.FlushBatch(completion: true);
                    }

                    trace.Stop();
                }

                return(profilerResult);

                #endregion
            },
                                                      cancellationToken, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);

            traceTask.ContinueWith((previousTask) => faulted.Set(), TaskContinuationOptions.AttachedToParent | TaskContinuationOptions.OnlyOnFaulted);
            traceTask.ContinueWith((previousTask) => collectorsSynchronizer.CompleteAdding(), TaskContinuationOptions.AttachedToParent | TaskContinuationOptions.ExecuteSynchronously);

            traceTask.Start();

            WaitHandle.WaitAny(new []
            {
                started,
                faulted
            });

            return(traceTask);
        }
 /// <summary>
 /// Requires there to be a procedure context.  Pops it.
 /// </summary>
 public void PopProcedureContext()
 {
     Contract.Requires(HasProcedureContext);
     Contract.Assert(procedureContext != null); // follows from precondition
     procedureContext = procedureContext.Next;
 }
Beispiel #33
0
 public static PerformanceResult CreateForPrepare(ProcedureContext procedureContext)
 {
     return(new PerformanceResult(procedureContext, counters: Enumerable.Empty <PerformanceCounter>()));
 }