示例#1
0
        protected async override void OnNavigatedFrom(NavigationEventArgs e)
        {
            await Task.Run(() =>
            {
                Cancellation.Cancel();
                ExitLocker.WaitOne();
                ExitLocker.Dispose();
                ExitLocker = null;
                Cancellation.Dispose();
                Cancellation = null;
            });

            Windows.ApplicationModel.Core.CoreApplication.LeavingBackground -= CoreApplication_LeavingBackground;
            Windows.ApplicationModel.Core.CoreApplication.EnteredBackground -= CoreApplication_EnteredBackground;

            if (Capture != null)
            {
                await Capture.ClearEffectsAsync(MediaStreamType.VideoPreview);

                if (Capture.CameraStreamState == Windows.Media.Devices.CameraStreamState.Streaming)
                {
                    await Capture.StopPreviewAsync();
                }

                Capture = null;
            }
            MediaCaptureProvider.Dispose();

            CaptureControl.Source = null;
            CosmeticsList.Clear();
            CosmeticsList = null;
            StayAwake.RequestRelease();
            StayAwake = null;
        }
示例#2
0
        private async void CoreApplication_EnteredBackground(object sender, EnteredBackgroundEventArgs e)
        {
            var Deferral = e.GetDeferral();

            await Capture.ClearEffectsAsync(MediaStreamType.VideoPreview);

            await Capture.StopPreviewAsync();

            Capture = null;
            MediaCaptureProvider.Dispose();

            CaptureControl.Source = null;

            StayAwake.RequestRelease();

            Deferral.Complete();
        }