I have a number of Janus controls that need to be filled in when the application starts.
I would like to load these grids into different threads in order to speed up the startup time and the time required to update these grids. Each grid is on a separate tab. Ideally, I would like to use Control.BeginInvoke in each grid and on loading the grid that completes the tabs, it will be turned on.
I know that with delegates you can perform an asynchronous callback when using BeginInvoke, so I can enable tabs in the asynchronous callback, however when using Control.BeginInvoke this is not possible. Is there a way to make asynchronous callbacks using Control.BeginInvoke, or perhaps a better solution?
So far, I:
public delegate void BindDelegate(IMyGrid grid);
private IAsyncResult InvokeBind(IMyGrid grid)
{
return ((Control)grid).BeginInvoke(
new BindDelegate(DoBind), new object[] { grid }
);
}
private void DoBind(IMyGrid grid)
{
grid.Bind();
}
private void RefreshComplete()
{
IAsyncResult grid1Asynch = InvokeBind(grid1);
IAsyncResult grid2Asynch = InvokeBind(grid2);
IAsyncResult grid3Asynch = InvokeBind(grid2);
IAsyncResult grid4Asynch = InvokeBind(grid3);
IAsyncResult grid5Asynch = InvokeBind(grid4);
IAsyncResult grid6Asynch = InvokeBind(grid5);
}
, IAsynchResults , , Tab, .