当前位置: 首页>>代码示例>>C#>>正文


C# Process.WaitForInputIdle方法代码示例

本文整理汇总了C#中Process.WaitForInputIdle方法的典型用法代码示例。如果您正苦于以下问题:C# Process.WaitForInputIdle方法的具体用法?C# Process.WaitForInputIdle怎么用?C# Process.WaitForInputIdle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Process的用法示例。


在下文中一共展示了Process.WaitForInputIdle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartProcess

 public void StartProcess(string path)
 {
     Process process = new Process();
     try
     {
         process.StartInfo.FileName = path;
         process.Start();
         process.WaitForInputIdle();
     }
     catch { }
 }
开发者ID:fgulsoy24,项目名称:Tu-Sinav-Derslik-Sistemi,代码行数:11,代码来源:Tvlistreport.aspx.cs

示例2: Connect

            public override bool Connect()
            {
                try
                {
                    _isPuttyNg = IsFilePuttyNg(PuttyPath);

                    PuttyProcess = new Process();
                    PuttyProcess.StartInfo.FileName = _PuttyPath;

                    switch (_PuttyProtocol) {
                        case Putty_Protocol.raw:
                                                PuttyProcess.StartInfo.Arguments = "-load " + "\"" + PuttyEscapeArgument(InterfaceControl.Info.PuttySession) + "\"" + " -" + _PuttyProtocol.ToString() + " -P " + InterfaceControl.Info.Port + " \"" + InterfaceControl.Info.Hostname + "\"";
                            break;
                        case Putty_Protocol.rlogin:
                            PuttyProcess.StartInfo.Arguments = "-load " + "\"" + PuttyEscapeArgument(InterfaceControl.Info.PuttySession) + "\"" + " -" + _PuttyProtocol.ToString() + " -P " + InterfaceControl.Info.Port + " \"" + InterfaceControl.Info.Hostname + "\"";
                            break;
                        case Putty_Protocol.ssh:
                            string userArgument = "";
                            string passwordArgument = "";

                            if (Settings.Default.EmptyCredentials == "windows") {
                                userArgument = " -l \"" + Environment.UserName + "\"";
                            }
                            else if (Settings.Default.EmptyCredentials == "custom")
                            {
                                userArgument = " -l \"" + Settings.Default.DefaultUsername + "\"";
                                passwordArgument = " -pw \"" + PuttyEscapeArgument(Security.Crypt.Decrypt(Settings.Default.DefaultPassword, AppInfo.General.EncryptionKey)) + "\"";
                            }

                            if (!string.IsNullOrEmpty(InterfaceControl.Info.Username)) {
                                userArgument = " -l \"" + InterfaceControl.Info.Username + "\"";
                            }

                            if (!string.IsNullOrEmpty(InterfaceControl.Info.Password)) {
                                passwordArgument = " -pw \"" + PuttyEscapeArgument(InterfaceControl.Info.Password) + "\"";
                            }

                            PuttyProcess.StartInfo.Arguments = "-load " + "\"" + PuttyEscapeArgument(InterfaceControl.Info.PuttySession)
                                + "\"" + " -" + _PuttyProtocol.ToString() + " -" + (int)_PuttySSHVersion + userArgument + passwordArgument
                                + " -P " + InterfaceControl.Info.Port + " \"" + InterfaceControl.Info.Hostname + "\"";
                            break;
                        case Putty_Protocol.telnet:
                            PuttyProcess.StartInfo.Arguments = "-load " + "\"" + PuttyEscapeArgument(InterfaceControl.Info.PuttySession) + "\"" + " -" + _PuttyProtocol.ToString() + " -P " + InterfaceControl.Info.Port + " \"" + InterfaceControl.Info.Hostname + "\"";
                            break;
                        case Putty_Protocol.serial:
                            PuttyProcess.StartInfo.Arguments = "-load " + "\"" + PuttyEscapeArgument(InterfaceControl.Info.PuttySession) + "\"" + " -" + _PuttyProtocol.ToString() + " -P " + InterfaceControl.Info.Port + " \"" + InterfaceControl.Info.Hostname + "\"";
                            break;
                    }

                    if (_isPuttyNg)
                    {
                        PuttyProcess.StartInfo.Arguments = PuttyProcess.StartInfo.Arguments + " -hwndparent " +
                                                           this.InterfaceControl.Handle.ToString();
                    }

                    //REMOVE IN RELEASE!
                #if DEBUG
                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        "PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments, true);
                    Debug.WriteLine("PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments);
                #endif
                    PuttyProcess.EnableRaisingEvents = true;
                    PuttyProcess.Exited += ProcessExited;

                    PuttyProcess.Start();
                    PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000);

                    int startTicks = Environment.TickCount;
                    while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000))
                    {
                        if (_isPuttyNg)
                        {
                            PuttyHandle = Native.FindWindowEx(InterfaceControl.Handle, IntPtr.Zero, Constants.vbNullString, Constants.vbNullString);
                        }
                        else
                        {
                            PuttyProcess.Refresh();
                            PuttyHandle = PuttyProcess.MainWindowHandle;
                        }
                        if (PuttyHandle.ToInt32() == 0)
                            Thread.Sleep(0);
                    }

                    if (!_isPuttyNg)
                    {
                        Native.SetParent(PuttyHandle, InterfaceControl.Handle);
                    }

                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strPuttyStuff,
                                                        true);

                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        string.Format(Language.strPuttyHandle, PuttyHandle.ToString()),
                                                        true);
                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        string.Format(Language.strPuttyTitle,
                                                                      PuttyProcess.MainWindowTitle), true);
                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        string.Format(Language.strPuttyParentHandle,
                                                                      this.InterfaceControl.Parent.Handle.ToString()),
//.........这里部分代码省略.........
开发者ID:jpmarques,项目名称:mRemoteNC,代码行数:101,代码来源:Connection.Protocol.PuttyBase.cs

示例3: Connect

            public override bool Connect()
            {
                try
                {
                    _isPuttyNg = IsFilePuttyNg(PuttyPath);

                    PuttyProcess = new Process();
                    var _with1 = PuttyProcess.StartInfo;
                    _with1.UseShellExecute = false;
                    _with1.FileName = _PuttyPath;

                    CommandLineArguments arguments = new CommandLineArguments();
                    arguments.EscapeForShell = false;

                    arguments.Add("-load", InterfaceControl.Info.PuttySession);
                    arguments.Add("-" + _PuttyProtocol.ToString());

                    if (_PuttyProtocol == Putty_Protocol.ssh)
                    {
                        string username = "";
                        string password = "";

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Username))
                        {
                            username = InterfaceControl.Info.Username;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "windows")
                            {
                                username = Environment.UserName;
                            }
                            else if (Settings.Default.EmptyCredentials == "custom")
                            {
                                username = Settings.Default.DefaultUsername;
                            }
                        }

                        if (!string.IsNullOrEmpty(InterfaceControl.Info.Password))
                        {
                            password = InterfaceControl.Info.Password;
                        }
                        else
                        {
                            if (Settings.Default.EmptyCredentials == "custom")
                            {
                                password = Security.Crypt.Decrypt(Settings.Default.DefaultPassword, AppInfo.General.EncryptionKey);
                            }
                        }

                        arguments.Add("-" + (int)_PuttySSHVersion);
                        arguments.Add("-l", username);
                        arguments.Add("-pw", password);
                    }

                    arguments.Add("-P", InterfaceControl.Info.Port.ToString());
                    arguments.Add(InterfaceControl.Info.Hostname);

                    if (_isPuttyNg)
                    {
                        arguments.Add("-hwndparent", InterfaceControl.Handle.ToString());
                    }

                    _with1.Arguments = arguments.ToString();

                    //REMOVE IN RELEASE!
                #if DEBUG
                    Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg,
                                                        "PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments, true);
                    Debug.WriteLine("PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments);
                #endif

                    PuttyProcess.EnableRaisingEvents = true;
                    PuttyProcess.Exited += ProcessExited;

                    PuttyProcess.Start();
                    PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000);

                    int startTicks = Environment.TickCount;
                    while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000))
                    {
                        if (_isPuttyNg)
                        {
                            PuttyHandle = Native.FindWindowEx(InterfaceControl.Handle, IntPtr.Zero, Constants.vbNullString, Constants.vbNullString);
                        }
                        else
                        {
                            PuttyProcess.Refresh();
                            PuttyHandle = PuttyProcess.MainWindowHandle;
                        }
                        if (PuttyHandle.ToInt32() == 0)
                            Thread.Sleep(50);
                    }

                    if (!_isPuttyNg)
                    {
                        Native.SetParent(PuttyHandle, InterfaceControl.Handle);
                    }

                    Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true);
//.........这里部分代码省略.........
开发者ID:824462811,项目名称:mRemoteNC,代码行数:101,代码来源:Connection.Protocol.PuttyBase.cs


注:本文中的Process.WaitForInputIdle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。