inconsistant behavior in Process.MainWindowHandle

C

codejunkie

Hi,

I am running a suite of tests of a WIN 32 application. Every test
launches the same application, checks if the Application has a Main
Window handle and then proceeds.
However i am noticing when i run a reasonably large ( 80-90) number of
tests one after the other the Main Window handle API displays
inconsistant behavior.

About 70% of the time my application returns a valid Main WIndow handle
and the rest of the time the value seems to be null. Now, the
inconsistancy here is that the tests that fail due to this issue are
different every time.

Are there any issues that i should be aware of ?
http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.mainwindowhandle.aspx

I am aware that MainWindowHandle will return Null of the process under
test is a Non - UI process but i am testing on a application similar to
word.

Any information will be of help. Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

codejunkie,

Are you calling WaitForInput idle like the documentation states? If you
are running 80-90 instances of an application, depending on the app, you
could be bogging down the system. It could be that the main window handle
has not been created yet, and you are getting the value before it is
available.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top