How to set the active view?

Your time is valuable - use it wisely:

Here’s RequestViewChange() in action from a post 2 years old. You can’t call this method in the background as it’s a UI call…which can only be made when Revit is full fired up, not open on disk (which incidentally answers your other question).