/// <summary>
        /// Handle request to start a profiling session
        /// </summary>
        internal async Task HandleCreateXEventSessionRequest(CreateXEventSessionParams parameters, RequestContext <CreateXEventSessionResult> requestContext)
        {
            await Task.Run(async() =>
            {
                try
                {
                    ConnectionInfo connInfo;
                    ConnectionServiceInstance.TryFindConnection(
                        parameters.OwnerUri,
                        out connInfo);
                    if (connInfo == null)
                    {
                        throw new Exception(SR.ProfilerConnectionNotFound);
                    }
                    else if (parameters.SessionName == null)
                    {
                        throw new ArgumentNullException("SessionName");
                    }
                    else if (parameters.Template == null)
                    {
                        throw new ArgumentNullException("Template");
                    }
                    else
                    {
                        IXEventSession xeSession = null;

                        // first check whether the session with the given name already exists.
                        // if so skip the creation part. An exception will be thrown if no session with given name can be found,
                        // and it can be ignored.
                        try
                        {
                            xeSession = this.XEventSessionFactory.GetXEventSession(parameters.SessionName, connInfo);
                        }
                        catch { }

                        if (xeSession == null)
                        {
                            // create a new XEvent session and Profiler session
                            xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
                        }

                        // start monitoring the profiler session
                        monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);

                        var result = new CreateXEventSessionResult();
                        await requestContext.SendResult(result);

                        SessionCreatedNotification(parameters.OwnerUri, parameters.SessionName, parameters.Template.Name);
                    }
                }
                catch (Exception e)
                {
                    await requestContext.SendError(new Exception(SR.CreateSessionFailed(e.Message)));
                }
            });
        }
        /// <summary>
        /// Handle request to start a profiling session
        /// </summary>
        internal async Task HandleCreateXEventSessionRequest(CreateXEventSessionParams parameters, RequestContext <CreateXEventSessionResult> requestContext)
        {
            try
            {
                ConnectionInfo connInfo;
                ConnectionServiceInstance.TryFindConnection(
                    parameters.OwnerUri,
                    out connInfo);
                if (connInfo == null)
                {
                    throw new Exception(SR.ProfilerConnectionNotFound);
                }
                else if (parameters.SessionName == null)
                {
                    throw new ArgumentNullException("SessionName");
                }
                else if (parameters.Template == null)
                {
                    throw new ArgumentNullException("Template");
                }
                else
                {
                    // create a new XEvent session and Profiler session
                    var xeSession = this.XEventSessionFactory.CreateXEventSession(parameters.Template.CreateStatement, parameters.SessionName, connInfo);
                    // start monitoring the profiler session
                    monitor.StartMonitoringSession(parameters.OwnerUri, xeSession);

                    var result = new CreateXEventSessionResult();
                    await requestContext.SendResult(result);

                    SessionCreatedNotification(parameters.OwnerUri, parameters.SessionName, parameters.Template.Name);
                }
            }
            catch (Exception e)
            {
                await requestContext.SendError(new Exception(SR.CreateSessionFailed(e.Message)));
            }
        }