I have a custom Winform Infopath UserControl which loads a form from a sharepoint library. I have a series of function calls, after opening the form, to pull some data from the form, even a take screenshot function. But the form load takes a lot of time, and the other functions finish up too quickly, much before the form load, which gives me wrong results.
Is there any way I can have a wait function, that waits for the infopath form to finish loading before the other functions are called?(in c#)
--Update
Example Code:
Inside the UserControl, I have a form initialize function, that basically loads the form
public void InitializeInfoPathForm(string myurl)
{
if (this.IsInitialized) return;
CreateForm(new Uri(myurl),null);
}
public void CreateForm(
Uri formUrlName,
Stream dataStream)
{
TestInitialization();
try
{
this.formControl.Close();
// Open / create a form
if (dataStream != null)
formControl.Open(
formUrlName.ToString()
);
else
{
formControl.Open(
formUrlName.ToString());
}
RefreshView(UIStatesForm.DocumentReadMode);
}
catch (Exception)
{
RefreshView(UIStatesForm.NoDocumentAvailable);
throw;
}
}
The Winform looks like this:
public partial class Form1 : Form
{
public Form1(string sharepoint_url)
{
InitializeComponent();
this.infoPathUserControl1.InitializeInfoPathForm(sharepoint_url);
takescreenshot();
}
}
I tried putting the takescreenshot() in a Form1_Load and Form1_Shown eventhandlers, but still the screenshots occur much earlier than the form load because FormControl.Open() takes a lot of time. I could put the screenshot function in a button_click event, but i want to automate this procedure. I even tried putting it ina button_click procedure and called button.PerformClick from the Form_Load eventhandler.
Pls Advice.