Reputation: 306
Is there a way to check if an application has finished loading.
For example if I were to use Process newProcess = Process.Start(@"C:\someFile.xls");
is there IsLoaded or IsFinishedLoading
or something similar to that, so that another line of code does not fire until the application is fully loaded.
I ask because I get an error when trying to interface with an excel sheet because its not open. Using only Process newProcess = Process.Start(@"C:\someFile.xls");
does the job but only after my application has crashed due to no excel document being open.
Now is there a way to speed up the starting of the program/file? Or have I coded something incorrectly.
Upvotes: 3
Views: 1568
Reputation: 11396
Since you are already using Interop, why not actually create the Excel Application, and load the document? You can also make the application visible to the user as well, if you need to.
using:
Excel.Application excel = new Excel.ApplicationClass();
Workbook wb = excel.Workbooks.Open(path, <parameters>);
Upvotes: 2
Reputation: 100527
There is no generic way to know when an application started or finished opening a document.
Some programs (i.e. Office applications) provide API to communicate/control them, while others (i.e. Notepad) have no way to know this information.
Upvotes: 3