A wrapper around AllocConsole, with some nice eventing to handle
Inheritance: IDisposable
Exemplo n.º 1
0
 private void MakeConsole()
 {
     if (_nativeConsole == null)
     {
         try
         {
             // don't initialize in the constructor
             _nativeConsole = new NativeConsole(false);
             // this way, we can handle (report) any exception...
             _nativeConsole.Initialize();
             _nativeConsole.WriteOutput += (source, args) => WriteNativeOutput(args.Text.TrimEnd('\n'));
             _nativeConsole.WriteError += (source, args) => WriteNativeError(args.Text.TrimEnd('\n'));
         }
         catch (ConsoleInteropException cie)
         {
             WriteNativeError("Couldn't initialize the Native Console: " + cie.Message);
         }
     }
 }
Exemplo n.º 2
0
 public void KillConsole()
 {
     _nativeConsole?.Dispose();
     _nativeConsole = null;
 }