public static WorkflowApplicationInstance EndAndCreateInstance(IAsyncResult result) { var thisPtr = AsyncResult.End <LoadAsyncResult>(result); Fx.AssertAndThrow(thisPtr.application == null, "Should not create a WorkflowApplicationInstance if we already have a WorkflowApplication"); var deserializedRuntimeState = WorkflowApplication.ExtractRuntimeState(thisPtr.values, thisPtr.persistenceManager.InstanceId); return(new WorkflowApplicationInstance(thisPtr.persistenceManager, thisPtr.values, deserializedRuntimeState.WorkflowIdentity)); }