Exemplo n.º 1
0
        public static void AttachProfilerToSelf(Guid profilerGuid, string profilerPath)
        {
            int processId            = Process.GetCurrentProcess().Id;
            DiagnosticsClient client = new DiagnosticsClient(processId);

            client.AttachProfiler(TimeSpan.MaxValue, profilerGuid, profilerPath, null);
        }
Exemplo n.º 2
0
        public Guid StartProfilingSession(int processId, ILogger logger)
        {
            string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string strWorkPath    = Path.GetDirectoryName(strExeFilePath);
            string profilerDll    = Path.Combine(strWorkPath, "profiler.dll");

            var sessionId = Guid.NewGuid();

            DiagnosticsClient client = new DiagnosticsClient(processId);

            client.AttachProfiler(TimeSpan.FromSeconds(10), ProfilerId, profilerDll, Encoding.UTF8.GetBytes(sessionId.ToString() + "\0"));

            logger.Log($"Attached profiler {ProfilerId} with session {sessionId} to process {processId}");

            return(sessionId);
        }
Exemplo n.º 3
0
    public static void AttachProfiler(int processId, Guid profilerGuid, string profilerPath)
    {
        var client = new DiagnosticsClient(processId);

        client.AttachProfiler(TimeSpan.FromSeconds(10), profilerGuid, profilerPath);
    }