当前位置: 首页>>代码示例>>C#>>正文


C# Windows.GetDeferral方法代码示例

本文整理汇总了C#中Windows.GetDeferral方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.GetDeferral方法的具体用法?C# Windows.GetDeferral怎么用?C# Windows.GetDeferral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows的用法示例。


在下文中一共展示了Windows.GetDeferral方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SourceGrid_DragStarting

 /// <summary>
 /// Start of the Drag and Drop operation: we set some content and change the DragUI
 /// depending on the selected options
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void SourceGrid_DragStarting(Windows.UI.Xaml.UIElement sender, Windows.UI.Xaml.DragStartingEventArgs args)
 {
     args.Data.SetText(SourceTextBox.Text);
     if ((bool)DataPackageRB.IsChecked)
     {
         // Standard icon will be used as the DragUIContent
         args.DragUI.SetContentFromDataPackage();
     }
     else if ((bool)CustomContentRB.IsChecked)
     {
         // Generate a bitmap with only the TextBox
         // We need to take the deferral as the rendering won't be completed synchronously
         var deferral = args.GetDeferral();
         var rtb = new RenderTargetBitmap();
         await rtb.RenderAsync(SourceTextBox);
         var buffer = await rtb.GetPixelsAsync();
         var bitmap = SoftwareBitmap.CreateCopyFromBuffer(buffer,
             BitmapPixelFormat.Bgra8,
             rtb.PixelWidth,
             rtb.PixelHeight,
             BitmapAlphaMode.Premultiplied);
         args.DragUI.SetContentFromSoftwareBitmap(bitmap);
         deferral.Complete();
     }
     // else just show the dragged UIElement
 }
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:32,代码来源:Scenario2_DragUICustomization.xaml.cs

示例2: Run

        public async void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
            try
            {
                DeviceConnectionChangeTriggerDetails details = (DeviceConnectionChangeTriggerDetails)taskInstance.TriggerDetails;
                BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(details.DeviceId);
                KeyFob device = new KeyFob(bleDevice);

                if (bleDevice.ConnectionStatus == BluetoothConnectionStatus.Connected)
                {
                    if (device.AlertOnDevice && device.HasLinkLossService)
                    {
                        await device.SetAlertLevelCharacteristic();
                    }
                }
                else
                {
                    if (device.AlertOnPhone)
                    {
                        XmlDocument xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                        xml.SelectSingleNode("/toast/visual/binding/text").InnerText = string.Format("Device {0} is out of range.", device.Name);
                        ToastNotification toast = new ToastNotification(xml);
                        ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
                        notifier.Show(toast);
                    }
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
开发者ID:MuffPotter,项目名称:201505-MVA,代码行数:33,代码来源:KeyFobTask.cs

示例3: GridDrop

        private async void GridDrop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var def = e.GetDeferral();
                var items = await e.DataView.GetStorageItemsAsync();
                var item = items.FirstOrDefault();

                if (item != null)
                {
                    var originalFile = item as StorageFile;
                    ViewModel.SetNewImage(originalFile);
                }

                e.Handled = true;
                def.Complete();
            }
        }
开发者ID:acasquete,项目名称:app-to-app-uwp,代码行数:18,代码来源:MainPage.xaml.cs

示例4: OnRun

 protected override void OnRun(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance)
 {
     BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
     System.Diagnostics.Debug.WriteLine("OnRun called!");
     UpdateTileAsync(_deferral);
 }
开发者ID:JulianMH,项目名称:ModernTimetable,代码行数:6,代码来源:AppTileUpdater.cs

示例5: AdaptiveMediaSource_DownloadRequested

        /// <summary>
        /// Called when the download of a DASH or HLS chunk is requested
        /// </summary>

        private async void AdaptiveMediaSource_DownloadRequested(Windows.Media.Streaming.Adaptive.AdaptiveMediaSource sender, Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceDownloadRequestedEventArgs args)
        {
//            LogMessage("DownloadRequested for uri: " + args.ResourceUri.ToString());
            
            var deferral = args.GetDeferral();
            if (deferral != null)
            {
                args.Result.ResourceUri = args.ResourceUri;
                args.Result.ContentType = args.ResourceType.ToString();
                var filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
                filter.CacheControl.WriteBehavior = Windows.Web.Http.Filters.HttpCacheWriteBehavior.NoCache;
                using (var httpClient = new Windows.Web.Http.HttpClient(filter))
                {
                    try
                    {
                        Windows.Web.Http.HttpRequestMessage request = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Get, args.Result.ResourceUri);
                        Windows.Web.Http.HttpResponseMessage response = await httpClient.SendRequestAsync(request);
                       // args.Result.ExtendedStatus = (uint)response.StatusCode;
                        if (response.IsSuccessStatusCode)
                        {
                            //args.Result.ExtendedStatus = (uint)response.StatusCode;
                            args.Result.InputStream = await response.Content.ReadAsInputStreamAsync();

                        }
                        else
                            LogMessage("DownloadRequested for uri: " + args.ResourceUri.ToString() + " error: " + response.StatusCode.ToString());
                    }
                    catch (Exception e)
                    {
                        LogMessage("DownloadRequested for uri: " + args.ResourceUri.ToString() + " exception: " + e.Message);

                    }
//                    LogMessage("DownloadRequested for uri: " + args.ResourceUri.ToString() + " done");
                    deferral.Complete();
                }
            }
            
        }
开发者ID:flecoqui,项目名称:Windows10,代码行数:42,代码来源:MainPage.xaml.cs


注:本文中的Windows.GetDeferral方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。