void OnEndLoad(IAsyncResult result) { WorkflowApplication instance = (WorkflowApplication)((object[])result.AsyncState)[0]; TextWriter instanceWriter = (TextWriter)((object[])result.AsyncState)[1]; try { instance.EndLoad(result); } catch (InstanceLockedException) { //don't load any instances for which we cannot aquire the lock this.hostView.ErrorWriter.WriteLine("Could not load existing instance because it was Locked."); return; } catch (InstancePersistenceException e) { this.hostView.ErrorWriter.WriteLine("Could not load existing instance due to an InstancePersistenceException: " + e.ToString()); } instance.Run(); AddInstance(new WorkflowApplicationState(instance, this, instanceWriter)); }