Giter Club home page Giter Club logo

warden's Introduction

Warden.NET

What Is It?

Warden.NET is a simple to use library for managing processes and their states.

Why?

With Rainway we're tasked with launching thousands of different applications from various third parties. To ensure launching games was a smooth process for the user, we needed a reliable way to keep track of game states.

The System.Diagnostics.Process class while useful does not have a concept for parent applications; while Windows itself does track parents, it does not track grandparents and processes can quickly become orphaned. Which is where Warden comes in.

Getting Started

Installing

Via Nuget

Install-Package Warden.NET

Initializing Warden

To initialize Warden inside your application, call the static initialization function. (Pass true if you'd like Warden to kill all monitored processes on exit.)

  WardenManager.Initialize(new WardenOptions
  {
                CleanOnExit = true,
                DeepKill = true,
                ReadFileHeaders = true
  });

Launching a Process

Warden processes are launched asynchronously and return null if it fails to launch.

If you wish to launch a Win32 application just call the following code.

var process = await WardenProcess.Start("G:/Games/steamapps/common/NieRAutomata/NieRAutomata.exe", string.empty, null);

Similarly, you can launch a UWP like so.

 var process = await  WardenProcess.StartUwp("Microsoft.Halo5Forge_8wekyb3d8bbwe", "!Ausar", string.Empty, null);

If you need to start a URI, that is also supported.

Pass the URI you wish to run, as well as the full path to the executable that should appear afterwards. This method will return an "empty" Warden object. The Id of the object will update automatically when the target process launches.

 var test = await WardenProcess.StartUriAsync("steam://run/107410", "G:/Games/steamapps/common/Arma 3/arma3launcher.exe", string.Empty, null, callback, token);

Or you can synchronously wait for a URI to start

 var test =  await WardenProcess.StartUri("steam://run/107410", "G:/Games/steamapps/common/Arma 3/arma3launcher.exe", string.Empty, null, token);

Finally, you can build a Warden process tree from an already running process like so

 WardenProcess.GetProcessFromId(999);

Listening to Process States

You can subscribe to OnProcessAdded to know when a process has been added to the tree, the OnStateChange event to know when a process state has updated. Additionally you can subscribe to OnChildStateChange to know when its children have had a change in state.

Notes

If you'd like to contribute we'll be happy to accept pull request. You can find a full example application in the repository.

warden's People

Contributors

calebnelton avatar battleguard avatar

Watchers

Thomas Guenther avatar James Cloos avatar

Forkers

evillord666

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.