コード例 #1
0
        private static void FireOnOutputDebugString(int pid, string text)
        {
            // Raise event if we have any listeners

#if !DEBUG
            try {
#endif
            OnOutputDebugString?.Invoke(pid, text);
#if !DEBUG
        }
        catch (Exception ex) {
            Console.WriteLine("An 'OnOutputDebugString' handler failed to execute: " + ex.ToString());
        }
#endif
        }
コード例 #2
0
ファイル: OdsMonitor.cs プロジェクト: stmanke/misc-how-to
        private static void FireOnOutputDebugString(int pid, string text)
        {
            // only re-emit if the pid is different from this process id
            if (pid != currentPid)
            {
                Debug.WriteLine($"[{pid}] {text}");

                // TODO: verify this is fast enough in real world, right now only tracking test app that
                // occassionally "mutters" debug string output
                var processes     = Process.GetProcesses();
                var pidsToMonitor = processes.Where(x => x.ProcessName.ToLower() == "muttercpp").Select(y => y.Id);

                // a subscriber AND we care? send it on! note: .Contains can be used on empty list, will return false
                if (pidsToMonitor.Contains(pid))
                {
                    OnOutputDebugString?.Invoke(pid, text);
                }
            }
        }