मुख्य सामग्री पर जाएँ
Skillpedia
API और सर्वर (backend)5.8k · #14655

process-api-net11

यह क्या करती है

यह स्किल बताती है कि .NET 11 के नए Process APIs से बाहरी प्रोग्राम कैसे चलाए जाएँ, उनका आउटपुट कैसे लिया जाए और उनका जीवनकाल कैसे संभाला जाए। यह उन डेवलपर्स के लिए है जो .NET 11 ऐप बना रहे हैं जो दूसरे प्रोग्राम शुरू करते हैं।

कब इस्तेमाल करें

  • ✓जब आपके .NET 11 ऐप को कोई बाहरी प्रोग्राम चलाकर उसका आउटपुट लेना हो।
  • ✓जब ऐप बंद होने पर चाइल्ड प्रोसेस अपने-आप बंद होने चाहिए।
  • ✓जब आपको अलग (detached) प्रोसेस शुरू करना हो या चाइल्ड कौन-से हैंडल विरासत में ले, यह नियंत्रित करना हो।

Skill का लिंक

https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/process-api-net11/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/dotnet/skills/blob/main/plugins/dotnet11/skills/process-api-net11/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे .NET 11 ऐप में एक कमांड-लाइन टूल चलाइए, उसका टेक्स्ट आउटपुट लीजिए, और पक्का कीजिए कि ऐप बंद होने पर वह भी बंद हो जाए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट नए .NET 11 प्रोसेस मेथड इस्तेमाल करता है जो प्रतीक्षा और आउटपुट कैप्चर संभालते हैं, और आपके माँगे गए लाइफ़टाइम विकल्प सेट करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Process API Improvements — .NET 11

New APIs added to System.Diagnostics.Process in .NET 11 simplify process management, eliminate boilerplate, and prevent common deadlock patterns when capturing output in .NET 11 or later applications.

When to Use

  • Running or orchestrating external processes in a .NET 11 (or later) project.
  • Needing to start a process, wait for it to exit, and capture its output/error streams without risking deadlocks (Process.RunAndCaptureText[Async]).
  • Wanting to ensure child processes are automatically terminated when the parent process exits (KillOnParentExit).
  • Requiring lightweight, low-overhead process creation via SafeProcessHandle on supported platforms.
  • Requiring fine-grained control over handle inheritance (InheritedHandles) or starting detached processes (StartDetached).

When Not to Use

  • The project targets .NET 10 or earlier — these APIs are not available before .NET 11.
  • The default Process.Start() is sufficient and does not require output capturing or advanced lifecycle rules.

Target Framework

<TargetFramework>net11.0</TargetFramework>

New APIs

Types

Before using the new convenience methods, note the following types. Use the framework types directly:

Type Kind Read-only properties
ProcessExitStatus Sealed class int ExitCode, bool Canceled, PosixSignal? Signal
ProcessTextOutput Sealed class ProcessExitStatus ExitStatus, string StandardOutput, string StandardError, int ProcessId
ProcessOutputLine Readonly struct string Content, bool StandardError

ProcessExitStatus describes the outcome of a completed process. Interpret ExitCode using the external command's contract; there is no universal Success property. ProcessTextOutput contains the exit status, captured output and error text, and process ID. ProcessOutputLine identifies one output line and whether it came from standard error.

High-Level Convenience APIs

Static Methods

The ProcessStartInfo overloads below require UseShellExecute = false, which is the default for .NET.

Process.Run / Process.RunAsync

Starts a process and waits for it to exit, returning the exit status. Does not capture standard output or error. Passing silent: true discards standard output and error by internally redirecting standard handles to the NUL device. On timeout or cancellation, the process is killed.

public static ProcessExitStatus Run(string fileName, IEnumerable<string>? arguments = null, bool silent = false, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(string fileName, IEnumerable<string>? arguments = null, bool silent = false, CancellationToken cancellationToken = default)
public static ProcessExitStatus Run(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessExitStatus> RunAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.RunAndCaptureText / Process.RunAndCaptureTextAsync

Starts a process, captures both standard output and error, and waits for it to exit. Extremely useful for avoiding deadlocks on stream redirection. On timeout or cancellation, the process is killed.

When using the ProcessStartInfo overloads, the caller is responsible for setting RedirectStandardOutput = true and RedirectStandardError = true on ProcessStartInfo (because BCL APIs cannot modify the input arguments they were given).

public static ProcessTextOutput RunAndCaptureText(string fileName, IEnumerable<string>? arguments = null, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(string fileName, IEnumerable<string>? arguments = null, CancellationToken cancellationToken = default)
public static ProcessTextOutput RunAndCaptureText(ProcessStartInfo startInfo, TimeSpan? timeout = null)
public static Task<ProcessTextOutput> RunAndCaptureTextAsync(ProcessStartInfo startInfo, CancellationToken cancellationToken = default)
Process.StartAndForget

There is a common misconception that when a process is disposed, it's also being killed. This is not the case, as Process.Dispose only releases the resources associated with the process, but does not kill it.

To make it easier to start a process without the need to worry about disposing it, Process.StartAndForget was introduced. The method starts an executable, retu

अक्सर पूछे जाने वाले सवाल

क्या यह .NET 10 पर काम करता है?

नहीं। ये API केवल .NET 11 और उसके बाद के वर्शन में हैं।

क्या डिफ़ॉल्ट Process.Start अब भी काम करता है?

हाँ। जब आपको आउटपुट कैप्चर या नए लाइफ़टाइम नियमों की ज़रूरत न हो, तब डिफ़ॉल्ट ठीक है।

KillOnParentExit क्या करता है?

इससे चाइल्ड प्रोसेस अपने-आप रुक जाते हैं, जब पैरेंट प्रोसेस खत्म होता है।

जानकारी

लेखक का मूल विवरण

Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.

repo: dotnet/skills

लोकप्रियता

GitHub स्टार
5.8k
रैंकिंग में स्थान
#14655
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills