system.diagnostics

C#: Redirect Standard Output of a Process that is Already Running

▼魔方 西西 提交于 2019-12-17 19:14:22
问题 I've been having a hard time getting the output of a "sub-process" (one launched internally by a blackbox process that I'm monitoring via c# System.Diagnostics.Process) I took the advice given by the answer of my previous post: here. And there you can find the details of what I've been going through. At this point, although I'm able to locate the ssh process spawned by process1.exe, that I'm monitoring. I can't redirect the output to my c# program, because it is an "already running process",

When should I use Tracing vs Logger.NET, Enterprise Library, log4net or Ukadc.Diagnostics?

只谈情不闲聊 提交于 2019-12-17 17:21:19
问题 How do I choose between standard tracing, Logger.NET, Enterprise Library, log4net or Ukadc.Diagnostics? Is there a situation where one is more appropriate than the other? ... what would that be? (ASP.NET, console app, Azure Cloud, SOHO, Enterprise...) What are the benefits or drawbacks? Did I miss any other major logging frameworks? 回答1: There are many similar questions here on SO: Logging best practices log4net versus TraceSource Silverlight Logging framework and/or best practices log4net vs

Can Stopwatch be used in production code?

不打扰是莪最后的温柔 提交于 2019-12-17 15:53:13
问题 I need an accurate timer, and DateTime.Now seems not accurate enough. From the descriptions I read, System.Diagnostics.Stopwatch seems to be exactly what I want. But I have a phobia. I'm nervous about using anything from System.Diagnostics in actual production code. (I use it extensively for debugging with Asserts and PrintLns etc, but never yet for production stuff.) I'm not merely trying to use a timer to benchmark my functions - my app needs an actual timer. I've read on another forum that

Is my process waiting for input?

大兔子大兔子 提交于 2019-12-17 15:44:25
问题 I am using the Process class to run an exe. The exe is a 3rd party console application that I do not control. I wish to know whether the process is waiting for input on the command line. Should it make any difference, I intend to kill the application should it be waiting for input. There are suitable events for when there is output from the program waiting to be read, but I cannot see anything similar for when the process is waiting patiently for input. ProcessStartInfo info = new

Reading error output hangs for command invoked on CMD process

吃可爱长大的小学妹 提交于 2019-12-13 08:11:26
问题 I have c# console app for ffmpeg command invocation. Here is it class Program { static void Main(string[] args) { ProcessStartInfo cmd = new ProcessStartInfo("cmd.exe"); cmd.RedirectStandardInput = true; cmd.RedirectStandardOutput = true; cmd.RedirectStandardError = true; cmd.UseShellExecute = false; cmd.CreateNoWindow = true; cmd.WindowStyle = ProcessWindowStyle.Hidden; Process console = Process.Start(cmd); console.StandardInput.WriteLine(@"cd C:\Users\vishnu.aravind"); console.StandardInput

Trace.CorrelationManager.ActivityId as WADLogsTable column

倖福魔咒の 提交于 2019-12-13 05:07:22
问题 Is there a way to have Trace.CorrelationManager.ActivityId automatically included as a column in the WADLogsTable when using System.Diagnostics tracing with Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener as the listener? 回答1: The new versions of Azure .NET SDK include an ActivityId column in the WAD tables, and you can include custom columns by using EventSource derived classes (just verified this on Azure SDK 2.6, although you need to make sure you are using .NET 4.5.1

Call a Console App from ASP.NET MVC, but don't want to wait for the response

这一生的挚爱 提交于 2019-12-12 02:14:30
问题 I am trying to achieve something like this. private Process p; // // GET: /Home/ [HttpGet] public ActionResult Index() { return View(new Contents() { Text = "Hello" }); } [HttpPost] public ActionResult Processing() { // Get the file path of your Application (exe) string filePath = @"Z:\Junk\MVCtoConsole\Sample Console App\bin\Debug\Sample Console App.exe"; ProcessStartInfo info = new ProcessStartInfo(filePath); info.RedirectStandardOutput = true; info.UseShellExecute = false; p = Process

Start and manage external process from a WPF app

坚强是说给别人听的谎言 提交于 2019-12-12 02:09:46
问题 I have a WPF application and I need to spin up a separate MFC application and then communicate with it. I was going to use Process.Start , but I'm wondering if there is a better way to do this these days. I can research things myself, but I need to know where to start. Thanks. Edits: I found this suggesting there isn't. Is this true? Alternatives to System.Diagnostics.Process.Start() Thanks. 回答1: For your immediate question, there is nothing new in the recent versions of .NET that gives a

Not all info about process in Process.GetProcesses when run in service by Local Service account

有些话、适合烂在心里 提交于 2019-12-11 13:22:43
问题 I have this code: [PermissionSet(SecurityAction.Assert, Name = "FullTrust")] public List<WinInfo> GetWindows() { try { var isFullTrust = Assembly.GetExecutingAssembly().IsFullyTrusted; if (isFullTrust) { return Process.GetProcesses().Where(z => !string.IsNullOrEmpty(z.MainWindowTitle)) .Select(z => new WinInfo { ProcessID = z.Id, ProcessName = z.ProcessName, WinID = z.MainWindowHandle, WindowTitle = z.MainWindowTitle }).ToList(); } else return null; } catch (Exception ex) { Trace.Write(ex

How to create an EventBookmark when querying the event log

℡╲_俬逩灬. 提交于 2019-12-11 10:06:01
问题 I have an EventLogReader object, and a query in the event log that looks like this: string query = "*[System[(Level=2) and TimeCreated[@SystemTime>='%LastRun%']]]") The code basically uses the reader to query for all the events that match the search query since the last time the reader was run. I would rather use the EventBookmark for this purpose. That's what it is for, after all! But I am having trouble finding any working code. My existing code run, in part, like this: // This line