A wrapper around AllocConsole, with some nice eventing to handle
Inheritance: IDisposable
Esempio 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);
         }
     }
 }
Esempio n. 2
0
 public void KillConsole()
 {
     _nativeConsole?.Dispose();
     _nativeConsole = null;
 }