I am implementing Perforce API in my application. For few long processes, I am trying to implement backgroudworker. I have done the implementation before many times, I know the in and outs of the BGW, but this time I am just not able to get results.
public P4()
{
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = true;
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
Recordset = p4.Run(p4command, p4args);
}
P4 is my constructor initializing BGW. I am calling it normally via RunWorkerAsync() method. bw_DoWork suppose to run p4.Run() but my Recordset is null (means command is not running). About p4command, its a global string containing command such as "integrate" and p4args is a global array containing arguments for the command, both are initialized from the base function.
Any idea what I am missing? (I also have bw_RunWorkerCompleted() which runs perfectly after bw_DoWork skips p4.run)
Thanks
EDIT: All functions related to BGW are in a separate class, P4, which has nothing to do with any GUI operations. I am calling P4.integrate() from a GUI which in turn call BGW. When I place P4.run() directly into P4.integrate() I get my results in Recordset, but placing this same command into bw_DoWork() seems not to work.
Async call is in P4 class, inside P4.integrate().
Thanks