I've got a button on a form that starts a process which, after x (varies) seconds, changes some data in a database table Y. The call InitializeGridView() then refreshes the DGV which shows previously mentioned table Y. Problem is that InitializeGridView() finishes before the process so the changes made by the process are not reflected. How do I make InitializeGridView wait for the process to complete?
private void btRunProcessAndRefresh_Click(object sender, EventArgs e){
Process.Start(@"\\fileserve\department$\ReportScheduler_v3.exe", "12");
InitializeGridView();
}
EDIT
I ended up with the following. Problem now is that if the process takes 10 minutes then the app is frozen for 10minutes. Think I need to learn how to multi thread!
private void btRunReport_Click(object sender, EventArgs e){
Process p = new Process();
p.StartInfo.FileName = @"\\fileserve\department$\ReportScheduler_v3.exe";
p.StartInfo.Arguments = "12";
p.Start();
p.WaitForExit();
InitializeGridView();
}