public async Task RemoveConnection() { try { await ManagementAgent.DeleteProfileAsync(ActiveProfile); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public async Task <VpnManagementConnectionStatus> GetStatusAsync() { var list = await ManagementAgent.GetProfilesAsync(); foreach (var profile in list) { if (profile is VpnNativeProfile) { var servers = await ConfigurationManager.GetServers(); foreach (var server in servers) { if (profile.ProfileName == Constants.connectionProfileName) { VpnNativeProfile nativeProfile = (VpnNativeProfile)profile; try { var status = nativeProfile.ConnectionStatus; if (status == VpnManagementConnectionStatus.Connected) { ActiveProfile = nativeProfile; return(status); } return(status); } catch (Exception) { await ManagementAgent.DeleteProfileAsync(nativeProfile); return(VpnManagementConnectionStatus.Disconnected); } } } } } return(VpnManagementConnectionStatus.Disconnected); }