private void CallbackMethod() { var failedlist = new List <string>(); try { Parallel.ForEach(_parsedListCache, (device) => { CancellationToken.Token.ThrowIfCancellationRequested(); if (!NetworkServices.VerifyDeviceConnectivity(device)) { failedlist.Add(device); ResultConsole.Instance.AddConsoleLine($"Device {device} failed connection verification. Added to failed list."); return; } _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, RemoteAccessEnabledKeyName, BoolToIntString(_remoteAccessEnabled).ToString(), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, RequiresUserApprovalKeyName, BoolToIntString(_requiresUserApproval), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, ShowConnectionBannerKeyName, BoolToIntString(_showConnectionBanner), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, ShowTaskbarIconKeyName, BoolToIntString(_showTaskBarIcon), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, AllowAccessOnUnattendedComputersKeyName, BoolToIntString(_allowAccessOnUnattended), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, AllowLocalAdministratorsToRemoteControlKeyName, BoolToIntString(_allowLocalAdministratorsToRemoteControl), RegistryValueKind.DWord); _registry.WriteToSubkey( device, RegistryHive.LocalMachine, SccmRemoteControlRegistryPath, AudibleSignalKeyName, BoolToIntString(_audibleSignal), RegistryValueKind.DWord); }); } catch (OperationCanceledException e) { ResetCancelToken(ActionName, e); } if (failedlist.Count > 0) { WriteToFailedLog(ActionName, failedlist); } }