Unmanaged Process in Mono

Posted by Residuum on Stack Overflow See other posts from Stack Overflow or by Residuum
Published on 2010-04-27T20:08:52Z Indexed on 2010/05/04 23:58 UTC
Read the original article Hit count: 236

Filed under:
|
|
|
|

I want to start a quite expensive process (jackd) from a Mono application, and do not need full access to the process from the application itself. As the process is so expensive in terms of CPU usage, a Glib.IdleHandler for polling the process will not work, as it is never executed, and the GUI becomes unresponsive. Is there any way to have the cake and eating it at the same time in Mono?

EDIT:

I only need to be able to start and stop the process from Mono, I do not need information about the state of the process or if it has exited, as my application will register itself as a client to jackd, basically I need a "replacement" for bash's jackd &>/dev/null 2>&1 & for the System.Diagnostics.Process ;).

Here is what I have so far for starting and stopping the process:

public void StartJackd()
{
    _jackd = new Process ();
    _jackd.StartInfo = _jackdStartup;
    if (_jackd.Start ())
    {
        _jackd.EnableRaisingEvents = true;
        _jackd.Exited += JackdExited;
    }
}

public void StopJackd()
{
    if (_jackd != null &&  !_jackd.HasExited)
    {
        _jackd.CloseMainWindow ();
    }
}

And somewhere else I have this code for registering the IdleHandler:

GLib.Idle.Add(new GLib.IdleHandler(UpdateJackdConnections));

This handler will fire all the time, while the process is not running, but never, when jackd is running.

© Stack Overflow or respective owner

Related posts about mono

Related posts about threads