Description
Code snippet for Shutdown and Restart of Windows 10 Core on Devices.
App Manifest
<Package xmlns=”http://schemas.microsoft.com/appx/manifest/foundation/windows10″ xmlns:mp=”http://schemas.microsoft.com/appx/2014/phone/manifest” xmlns:uap=”http://schemas.microsoft.com/appx/manifest/uap/windows10″ xmlns:iot=”http://schemas.microsoft.com/appx/manifest/iot/windows10″ IgnorableNamespaces=”uap mp iot“>
Code (VB.NET)
Imports System Imports Windows.System Imports System.Globalization Imports Windows.UI.Popups Imports Windows.UI.Xaml Public NotInheritable Class MainPage Inherits Page Private Async Sub btRestart_Click(sender As Object, e As RoutedEventArgs) Handles btRestart.Click Dim msgbox As New ContentDialog With {.Title = "Restart this device?"} msgbox.PrimaryButtonText = "Restart" msgbox.SecondaryButtonText = "Cancel" Dim result As ContentDialogResult = Await msgbox.ShowAsync() If result = ContentDialogResult.Primary Then ShutdownManager.BeginShutdown(ShutdownKind.Restart, New TimeSpan(0)) End If End Sub Private Async Sub btShudown_Click(sender As Object, e As RoutedEventArgs) Handles btShutdown.Click Dim msgbox As New ContentDialog With {.Title = "Shutdown this device?"} msgbox.PrimaryButtonText = "Shutdown" msgbox.SecondaryButtonText = "Cancel" Dim result As ContentDialogResult = Await msgbox.ShowAsync() If result = ContentDialogResult.Primary Then ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, New TimeSpan(0)) End If End Sub Private Sub MainPage_Loading(sender As FrameworkElement, args As Object) Handles Me.Loading 'IMPORTANT Dim culture = New System.Globalization.CultureInfo("en-AU") Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset() Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset() End Sub End Class
References
Applies to:
Article Rating: