void onFeatureWrapper(object nothing, EventArrivedEventArgs args) { // If this session is already in a transaction we must // wait for it to finish, otherwise we may not correctly // read the controlKey wmisession.AwaitTransactionCompletion(); try { if (enabled && ((!controlmustexist) || controlKey.Exists())) { onFeature(); } } catch (System.Management.ManagementException e) { enabled = false; if (e.ErrorCode == ManagementStatus.AccessDenied) { wmisession.Log("Feature " + name + " disabled"); } else { throw e; } } catch (Exception e) { enabled = false; //Don't want to call the feature if it causes an exception exceptionhandler.HandleException("Feature " + name, e); } }