コード例 #1
0
        /// <summary>
        /// Determines the run type and executes the built scaffold appropriately.
        /// </summary>
        /// <param name="defaultRunType">The default run type the application will fall back to</param>
        /// <param name="scaffold">The scaffold built.</param>
        /// <param name="arguments">The console arguments.</param>
        /// <param name="type">The object to pass.</param>
        public static void DispatchExecutor(HybridScaffold scaffold, string[] arguments, Type type, RunType defaultRunType = RunType.Console)
        {
            var processInfo = ParentProcess.ConsoleScaffolding(defaultRunType);

            scaffold.RunType     = processInfo.RunType;
            scaffold.ProcessName = processInfo.ProcessName;
            scaffold.CommandName = processInfo.CommandName;

            if (arguments == null && type == null)
            {
                throw new InvalidOperationException(ErrorStrings.InvalidOpperationError);
            }
            else
            {
                switch (scaffold.RunType)
                {
                case RunType.Console:
                case RunType.Powershell:
                {
                    var outputArguments = scaffold.PreConsoleExec(arguments, scaffold.RunType);
                    scaffold.ConsoleMain(outputArguments, scaffold.RunType);
                }
                break;

                case RunType.Gui:
                {
                    var outputObject = scaffold.PreGuiExec(arguments, (object)Activator.CreateInstance(type));
                    scaffold.GuiMain(arguments, outputObject);
                }
                break;
                }
            }
        }
コード例 #2
0
 public override bool Exit(bool force)
 {
     if (process == null)
     {
         return(true);
     }
     process.Refresh();
     if (process.HasExited)
     {
         return(true);
     }
     return(ParentProcess.Exit(force) && process.WaitForExit(force));
 }
コード例 #3
0
ファイル: XTMFUpdateForm.cs プロジェクト: lunaxi7/XTMF
 public XTMFUpdateForm()
 {
     InitializeComponent();
     Controller                       = new UpdateController();
     Controller.XtmfUpdate            = this;
     ArchitectureSelect.SelectedIndex = 0;
     if (ParentProcess != null)
     {
         UpdateButton.Enabled = false;
         Task.Factory.StartNew(() =>
         {
             if (!ParentProcess.HasExited)
             {
                 ParentProcess.WaitForExit();
             }
             Invoke(new Action(() =>
             {
                 UpdateButton.Enabled = true;
             }));
         });
     }
 }
コード例 #4
0
 public static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         App app = new App();
         app.InitializeComponent();
         app.Run();
     }
     else
     {
         //Debugger.Launch();
         _parentProcess = new ParentProcess(args);
         _parentProcess.MessageReceived   += ParentProcess_MessageReceived;
         _parentProcess.ParentProcessExit += ParentProcess_ParentProcessExit;
         if (_parentProcess.InputArgs.Length != 4)
         {
             return;
         }
         try
         {
             _realPhone = new RealPhone(_parentProcess.InputArgs[0], _parentProcess.InputArgs[1],
                                        _parentProcess.InputArgs[2], Convert.ToInt32(_parentProcess.InputArgs[3]));
             _realPhone.StateChanged        += _realPhone_StateChanged;
             _realPhone.StateMessageChanged += _realPhone_StateMessageChanged;
             _realPhone.RaiseMessage        += _realPhone_RaiseMessage;
         }
         catch (Exception ex)
         {
             _parentProcess.SendMessage($"$I:{ex.Message}");
         }
         while (!_exit)
         {
             Thread.Sleep(500);
         }
         _realPhone?.Dispose();
     }
 }
コード例 #5
0
 public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcess processInformation, int processInformationLength, out int returnLength);
コード例 #6
0
ファイル: Ntdll.cs プロジェクト: roomaroo/coapp.powershell
 public static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcess processInformation, int processInformationLength, out int returnLength);