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