Pergunta

After initiating a new project, I would like to know when Petrel has completed the new project creation. When subscribed to the DataManager.WorkspaceOpened event, the event get called when the workspace is opened, but this may not be when the main thread has completed creating the new project.

Any ideas on when to know when Petrel is finished creating the new project ?

Foi útil?

Solução

Perhaps you can try to find another way to solve your underlying problem than listening for the project event? Could you do a lazy evaluation and wait until the user actually need your code to do what it will do after the project is loaded?

Sometimes you might end up chasing these kind of problems in a circle: I need A to happen after B, and B to happen after C, and C to happen after A.

Anyway... here is a hack that you can try in you IModule:

void WorkspaceOpened(object sender, EventArgs e)
{
    Application.Idle += new EventHandler(Application_Idle);
}

void Application_Idle(object sender, EventArgs e)
{
    // Deatach from this, since this event can be raised 100 times per second, 
    // and we only want it once per project.
    Application.Idle -= new EventHandler(Application_Idle);

    DoMyStuffHereAfterTheProjectHasFinishedOpening();
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top