/// <summary> /// Runs the specified delegate in the specified apartment /// </summary> private static void RunInApartment(ThreadStart userDelegate, ApartmentState apartment) { if (apartment == ApartmentState.Unknown) { throw new InvalidOperationException("Can only run in STAs or MTAs"); } ApartmentOperationRunner runner = new ApartmentOperationRunner(); runner.Run(userDelegate, apartment); }