public async Task <Stream> GetDump(IProcessInfo pi, DumpType mode, CancellationToken token) { string dumpFilePath = Path.Combine(Path.GetTempPath(), FormattableString.Invariant($"{Guid.NewGuid()}_{pi.ProcessId}")); NETCore.Client.DumpType dumpType = MapDumpType(mode); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Get the process Process process = Process.GetProcessById(pi.ProcessId); await Dumper.CollectDumpAsync(process, dumpFilePath, dumpType); } else { await Task.Run(() => { pi.Client.WriteDump(dumpType, dumpFilePath); }); } return(new AutoDeleteFileStream(dumpFilePath)); }
public async Task <Stream> GetDump(int pid, DumpType mode) { string dumpFilePath = FormattableString.Invariant($@"{Path.GetTempPath()}{Path.DirectorySeparatorChar}{Guid.NewGuid()}_{pid}"); NETCore.Client.DumpType dumpType = MapDumpType(mode); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Get the process Process process = Process.GetProcessById(pid); await Dumper.CollectDumpAsync(process, dumpFilePath, dumpType); } else { await Task.Run(() => { var client = new DiagnosticsClient(pid); client.WriteDump(dumpType, dumpFilePath); }); } return(new AutoDeleteFileStream(dumpFilePath)); }