❔ limit network usage of a process
is it posible to limit the network usage of a certain process? and if it is how can it be done?
7 Replies
there are different ways to achieve this. One is to use the Windows Firewall API.
Exactly how you might write a method to limit the network usage of a process depends on what exactly you want to do.
well I got a forms up and eas thinking of having a textbox where I could type the limit in bytes and activate that when the checkbox is checked.
also the process i want to limit will be hard coded somewhere
public static void LimitNetworkUsage(process process, long limitBytes)
{
// Set the process's priority
process.PriorityClass = ProcessPriorityClass.BelowNormal;
// Set the process's ProcessorAffinity
process.ProcessorAffinity = (IntPtr)1;
// set the limitBytes
process.MaxWorkingSet = new IntPtr(limitBytes);
}
public static void RemoveLimit(process process)
{
// Set the process's priority
process.PriorityClass = ProcessPriorityClass.Normal;
// Remove the limit
process.MaxWorkingSet = new IntPtr(-1);
}
These two methods must be able to add and delete a network usage limit for a process
thanks ✌🏻
Don't use ChatGPT to answer people's questions... that limits the memory usage, not network. ChatGPT is basically always wrong
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.