本文整理汇总了C#中System.Diagnostics.Process.WaitForInputIdle方法的典型用法代码示例。如果您正苦于以下问题:C# Process.WaitForInputIdle方法的具体用法?C# Process.WaitForInputIdle怎么用?C# Process.WaitForInputIdle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.WaitForInputIdle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window
public Window(Process p, string className, string rootElementName)
{
this.p = p;
IntPtr h = p.Handle;
while (h == IntPtr.Zero || !p.Responding)
{
Sleep(1000);
p.WaitForInputIdle();
h = p.Handle;
if (p.HasExited)
{
throw new InvalidOperationException(string.Format("Process '{0}' has exited!", p.StartInfo.FileName));
}
}
p.WaitForInputIdle();
p.Exited += new EventHandler(OnExited);
int id = p.Id;
if (this.acc == null)
{
// p.MainWindowHandle always returns 0 for some unknown reason...
int retries = 20;
while (retries-- > 0 && this.acc == null)
{
this.acc = FindWindowForProcessId(id, className, rootElementName);
Sleep(1000);
}
if (this.acc == null)
{
throw new Exception("Process as no window handle");
}
this.handle = this.acc.Hwnd;
}
}
示例2: Init
public void Init()
{
string tePath = SIL.FieldWorks.Common.Utils.DirectoryFinder.GetFWCodeFile(@"\..\Output\Debug\TE.exe");
m_proc = Process.Start(tePath);
m_proc.WaitForInputIdle();
while (Process.GetProcessById(m_proc.Id).MainWindowHandle == IntPtr.Zero)
Thread.Sleep(100);
m_proc.WaitForInputIdle();
Win32.SetForegroundWindow(m_proc.MainWindowHandle);
m_ah = new AccessibilityHelper(m_proc.MainWindowHandle);
}
示例3: Init
public void Init()
{
CheckDisposed();
m_proc = Process.Start(@"DummyTestExe.exe");
m_proc.WaitForInputIdle();
while (Process.GetProcessById(m_proc.Id).MainWindowHandle == IntPtr.Zero)
Thread.Sleep(100);
m_proc.WaitForInputIdle();
Win32.SetForegroundWindow(m_proc.MainWindowHandle);
m_ah = new AccessibilityHelper(m_proc.MainWindowHandle);
}
示例4: Execute
public override void Execute(TestState ts)
{
bool fStarted = true;
string fullPath = m_path + @"\" + m_exeName;
// if the app is already running, close it first
AppHandle app = Application;
if (app != null && app.ExePath == fullPath)
{
if (app.Process != null)
{
app.Process.Kill();
app.Process.WaitForExit(3000);
}
}
m_proc = Process.Start(fullPath);
if (m_proc == null)
fStarted = false;
m_proc.WaitForInputIdle();
while (Process.GetProcessById(m_proc.Id).MainWindowHandle == IntPtr.Zero)
Thread.Sleep(100);
if (m_proc.HasExited)
fStarted = false;
m_proc.WaitForInputIdle();
Win32.SetForegroundWindow(m_proc.MainWindowHandle);
Assertion.AssertEquals(true, fStarted);
Assertion.AssertNotNull("Null process", m_proc);
Assertion.AssertNotNull("Null window handle", m_proc.MainWindowHandle);
}
示例5: OnStart
protected override void OnStart(string[] args)
{
var exePath = GetExeLocation(args);
if (!File.Exists(exePath))
{
var message = string.Format("The file {0} could not be found.", exePath);
this.EventLog.WriteEntry(message, EventLogEntryType.Error);
Environment.Exit(1);
}
ProcessStartInfo psi = new ProcessStartInfo(exePath);
psi.UseShellExecute = true;
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
try
{
this.process = Process.Start(psi);
if (this.process != null)
{
process.WaitForInputIdle();
}
}
catch (Exception ex)
{
var message = string.Format("Executing the utorrent.exe failed: {0}", ex);
this.EventLog.WriteEntry(message, EventLogEntryType.Error);
Environment.Exit(2);
}
}
示例6: StartIfNotRunning
public static void StartIfNotRunning()
{
foreach (var process in Process.GetProcesses())
{
if (process.ProcessName == "scktsrvr")
return;
}
var newProcess = new Process();
newProcess.StartInfo = new ProcessStartInfo()
{
FileName = GetSocketServerPath()
};
newProcess.Start();
newProcess.WaitForInputIdle(1000);
for (int i = 0; i < 100; i++)
{
foreach (var process in Process.GetProcesses())
{
if (process.ProcessName == "scktsrvr")
{
return;
}
}
Thread.Sleep(100);
}
Logger.Error("NativeFiresecClient.StartSocketServerIfNotRunning не удалось запустить процесс scktsrvr");
}
示例7: Client
/// <summary>
/// Main constructor
/// </summary>
/// <param name="p">the client's process object</param>
public Client(Process p)
{
Process = p;
Process.Exited += new EventHandler(process_Exited);
Process.EnableRaisingEvents = true;
// Wait until we can really access the process
Process.WaitForInputIdle();
while (Process.MainWindowHandle == IntPtr.Zero)
{
Process.Refresh();
System.Threading.Thread.Sleep(5);
}
// Save a copy of the handle so the process doesn't have to be opened
// every read/write operation
Handle = Util.WinAPI.OpenProcess(Util.WinAPI.PROCESS_ALL_ACCESS, 0, (uint)Process.Id);
PathFinder = new Pokemon.Util.AStarPathFinder(this);
Inventory = new Objects.Inventory(this);
BattleList = new Objects.BattleList(this);
Map = new Objects.Map(this);
Memory = new MemoryHelper(this);
Window = new Window(this);
IO = new IOHelper(this);
Login = new LoginHelper(this);
Dll = new DllHelper(this);
Input = new InputHelper(this);
Player = new PlayerHelper(this);
// Save the start time (it isn't changing)
startTime = Memory.ReadInt32(Addresses.Client.StartTime);
}
示例8: Run
public string Run(string command)
{
if (_State == State.Idle)
{
_Process = new Process();
_Process.StartInfo = new ProcessStartInfo("cmd", "/c " + command)
{
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = false
};
_Process.OutputDataReceived += new DataReceivedEventHandler(DataReceived);
_Process.Start();
_Process.BeginOutputReadLine();
while(_Process.WaitForInputIdle()) {
_State = State.Waiting;
}
}
string output = "";
/*
string output = ">>" + command + "\n";
output += _Process.StandardOutput.ReadToEnd();
string error = _Process.StandardError.ReadToEnd();
output += error;
output += "\n";*/
_Process.WaitForExit();
_Process.Close();
_State = State.Idle;
return output;
}
示例9: pbButton_Click
private void pbButton_Click(object sender, EventArgs e)
{
RunApp r = new RunApp();
contentPath = @"D:\workspace\of_v0.8.4_vs_release\apps\PegasusHighwaysHotelKidsZone\bin\PegasusHighwaysHotelLauncher\PegasusHighwaysHotelLauncher.exe";
ProcessStartInfo contentInfo = new ProcessStartInfo();
contentInfo.FileName = contentPath;
contentInfo.WorkingDirectory = Path.GetDirectoryName(contentPath);
contentInfo.UseShellExecute = true;
contentInfo.CreateNoWindow = true;
contentInfo.WindowStyle = ProcessWindowStyle.Maximized;
contentInfo.RedirectStandardInput = false;
contentInfo.RedirectStandardOutput = false;
contentInfo.RedirectStandardError = false;
content = Process.Start(contentInfo);
content.WaitForInputIdle();
SetParent(content.MainWindowHandle, this.Handle);
content.EnableRaisingEvents = true;
content.Exited += Content_Exited;
while (!content.Responding)
{
Game_Loaded();
}
}
示例10: Window
public Window(Process p)
{
this.p = p;
IntPtr h = p.Handle;
while (h == IntPtr.Zero || !p.Responding) {
Sleep(1000);
p.WaitForInputIdle();
h = p.Handle;
if (p.HasExited) {
throw new InvalidOperationException(string.Format("Process '{0}' has exited!", p.StartInfo.FileName));
}
}
p.Exited += new EventHandler(OnExited);
int id = p.Id;
if (handle == IntPtr.Zero) {
// p.MainWindowHandle always returns 0 for some unknown reason...
int retries = 20;
while (retries-- > 0 && handle == IntPtr.Zero) {
handle = FindWindowForProcessId(id);
Sleep(1000);
}
if (handle == IntPtr.Zero) {
throw new Exception("Process as no window handle");
}
}
this.acc = SystemAccessible.AccessibleObjectForWindow(handle);
}
示例11: should_print_and_save_notepad_file
public void should_print_and_save_notepad_file()
{
//arrange
string path = @"E:\test.txt";
if (File.Exists(path))
{
File.Delete(path);
}
//act
Process excelProc = new Process();
excelProc.StartInfo.FileName = "notepad.exe";
excelProc.Start();
excelProc.WaitForInputIdle();
TestStack.White.Application app = TestStack.White.Application.Attach("notepad");
var wndMain = app.GetWindows()[0];
SendKeys.SendWait("Some Text For Printing and Saving");
Thread.Sleep(200);
//Call Print Dialog
SendKeys.SendWait("^{p}");
//Print
ClickBtn(FindWnd(app), "1");
//Cancel
ClickBtn(FindWnd(app), "2");
//Abort Accept
ClickBtn(FindWnd(app), "2");
//Call Save Dialog
SendKeys.SendWait("^{s}");
var saveDlg = FindWnd(app);
var list = saveDlg.Get<TestStack.White.UIItems.TreeItems.Tree>(SearchCriteria.ByAutomationId("100"));
var desktop = list.Nodes[1];
desktop.Expand();
var thisPC = desktop.Nodes[2];
thisPC.Expand();
var diskC = thisPC.Nodes.FirstOrDefault(n => n.Text == "Локальный диск (E:)");
diskC.Select();
var fileName = saveDlg.Get<TestStack.White.UIItems.TextBox>(SearchCriteria.ByAutomationId("1001"));
fileName.Text = "test";
var btnSave = saveDlg.Get<TestStack.White.UIItems.Button>(SearchCriteria.ByAutomationId("1"));
btnSave.Click();
SendKeys.SendWait("%{F4}");
excelProc.WaitForExit();
bool res = File.Exists(path);
//assert
Assert.AreEqual(true, res);
}
示例12: RunAndPrintNotepad
public void RunAndPrintNotepad()
{
Process notepad = new Process();
notepad.StartInfo.FileName = "notepad.exe";
notepad.Start();
notepad.WaitForInputIdle();
SendKeys.SendWait(StringExample);
PrintDocument();
}
示例13: BuildWindowCore
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
{
_hwndHost = IntPtr.Zero;
_hwndHost = NativeMethods.CreateWindowEx(
0, "static", "",
NativeMethods.WsChild | NativeMethods.WsVisible | NativeMethods.WsClipChildren,
0, 0,
_hostWidth, _hostHeight,
hwndParent.Handle,
IntPtr.Zero,
IntPtr.Zero,
0);
// This code uses Thread.Sleep, so finish on a background thread
Task.Factory.StartNew(() =>
{
string haloExePath = App.MetroIdeStorage.MetroIdeSettings.HaloExePath;
if (!File.Exists(haloExePath)) return;
string haloDirectory = Path.GetDirectoryName(haloExePath);
if (haloDirectory == null || !Directory.Exists(haloDirectory)) return;
_haloProcess = Process.Start(new ProcessStartInfo(haloExePath)
{
WorkingDirectory = haloDirectory,
Arguments = string.Format(@"-console -window -vidmode {0},{1},60", 800, 600),
WindowStyle = ProcessWindowStyle.Minimized
});
_haloProcess.WaitForInputIdle();
Thread.Sleep(2000);
// remove control box
int style = NativeMethods.GetWindowLong(_haloProcess.MainWindowHandle, NativeMethods.GwlStyle);
style = style & ~NativeMethods.WsCaption & ~NativeMethods.WsThickframe;
NativeMethods.SetWindowLong(_haloProcess.MainWindowHandle, NativeMethods.GwlStyle, style);
// reveal and relocate into our window
NativeMethods.SetParent(_haloProcess.MainWindowHandle, _hwndHost);
NativeMethods.ShowWindow(_haloProcess.MainWindowHandle, NativeMethods.SwShow);
// resize
NativeMethods.SetWindowPos(_haloProcess.MainWindowHandle, IntPtr.Zero, 0, 0, 800, 600, NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate);
// force video rendering
const int exeOffset = 0x400000;
const int wmkillHandlerOffset = exeOffset + 0x142538;
var wmkillHandler = new WinMemoryByteAccess(wmkillHandlerOffset, 4);
wmkillHandler.WriteBytes(0, new byte[] { 0xe9, 0x91, 0x00, 0x00 });
});
return new HandleRef(this, _hwndHost);
}
示例14: Connect
public override bool Connect()
{
try
{
if (_externalTool.TryIntegrate == false)
{
_externalTool.Start(InterfaceControl.Info);
Close();
return false;
}
ExternalToolArgumentParser argParser = new ExternalToolArgumentParser(_externalTool.ConnectionInfo);
_process = new Process();
_process.StartInfo.UseShellExecute = true;
_process.StartInfo.FileName = argParser.ParseArguments(_externalTool.FileName);
_process.StartInfo.Arguments = argParser.ParseArguments(_externalTool.Arguments);
_process.EnableRaisingEvents = true;
_process.Exited += ProcessExited;
_process.Start();
_process.WaitForInputIdle(Convert.ToInt32(Settings.Default.MaxPuttyWaitTime * 1000));
int startTicks = Environment.TickCount;
while (_handle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000))
{
_process.Refresh();
if (_process.MainWindowTitle != "Default IME")
{
_handle = _process.MainWindowHandle;
}
if (_handle.ToInt32() == 0)
{
Thread.Sleep(0);
}
}
NativeMethods.SetParent(_handle, InterfaceControl.Handle);
Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strIntAppStuff, true);
Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppHandle, _handle.ToString()), true);
Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppTitle, _process.MainWindowTitle), true);
Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppParentHandle, InterfaceControl.Parent.Handle.ToString()), true);
Resize(this, new EventArgs());
base.Connect();
return true;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionMessage(Language.strIntAppConnectionFailed, ex);
return false;
}
}
示例15: ClientMC
public ClientMC(Process p)
{
process = p;
process.WaitForInputIdle();
while (process.MainWindowHandle == IntPtr.Zero)
{
process.Refresh();
System.Threading.Thread.Sleep(5);
}
processHandle = WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, (uint)process.Id);
}