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


C# IAsyncOperation.GetResults方法代码示例

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


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

示例1: OnMessageDialogShowAsyncCompleted

        void OnMessageDialogShowAsyncCompleted(IAsyncOperation<IUICommand> asyncInfo, AsyncStatus asyncStatus) {
            // Get the Color value
            IUICommand command = asyncInfo.GetResults();
            clr = (Color)command.Id;

            // Use a Dispatcher to run in the UI thread
            IAsyncAction asyncAction = this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                OnDispatcherRunAsyncCallback);
        }
开发者ID:ronlemire2,项目名称:UWP-Testers,代码行数:9,代码来源:HowToAsync1Page.xaml.cs

示例2: GetConnectivityIntervalsAsyncHandler

        async private void GetConnectivityIntervalsAsyncHandler(IAsyncOperation<IReadOnlyList<ConnectivityInterval>> asyncInfo, AsyncStatus asyncStatus)
        {
            if (asyncStatus == AsyncStatus.Completed)
            {
                try
                {
                    String outputString = string.Empty;
                    IReadOnlyList<ConnectivityInterval> connectivityIntervals = asyncInfo.GetResults();

                    if (connectivityIntervals == null)
                    {
                        rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                rootPage.NotifyUser("The Start Time cannot be later than the End Time, or in the future", NotifyType.StatusMessage);
                            });
                        return;
                    }

                    // Get the NetworkUsage for each ConnectivityInterval
                    foreach (ConnectivityInterval connectivityInterval in connectivityIntervals)
                    {
                        outputString += PrintConnectivityInterval(connectivityInterval);

                        DateTimeOffset startTime = connectivityInterval.StartTime;
                        DateTimeOffset endTime = startTime + connectivityInterval.ConnectionDuration;
                        IReadOnlyList<NetworkUsage> networkUsages = await InternetConnectionProfile.GetNetworkUsageAsync(startTime, endTime, Granularity, NetworkUsageStates);

                        foreach (NetworkUsage networkUsage in networkUsages)
                        {
                            outputString += PrintNetworkUsage(networkUsage, startTime);
                            startTime += networkUsage.ConnectionDuration;
                        }
                    }

                    rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            rootPage.NotifyUser(outputString, NotifyType.StatusMessage);
                        });
                }
                catch (Exception ex)
                {
                    rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            rootPage.NotifyUser("An unexpected error occurred: " + ex.Message, NotifyType.ErrorMessage);
                        });
                }
            }
            else
            {
                rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        rootPage.NotifyUser("GetConnectivityIntervalsAsync failed with message:\n" + asyncInfo.ErrorCode.Message, NotifyType.ErrorMessage);
                    });
            }
        }
开发者ID:mbin,项目名称:Win81App,代码行数:55,代码来源:ProfileLocalUsageData.xaml.cs

示例3: AppServiceConnectionCompleted

 void AppServiceConnectionCompleted(IAsyncOperation<AppServiceConnectionStatus> operation, AsyncStatus asyncStatus)
 {
     var status = operation.GetResults();
     if (status == AppServiceConnectionStatus.Success)
     {
         var secondOperation = _appServiceConnection.SendMessageAsync(null);
         secondOperation.Completed = (_, __) =>
         {
             _appServiceConnection.Dispose();
             _appServiceConnection = null;
         };
     }
 }
开发者ID:File-New-Project,项目名称:EarTrumpet,代码行数:13,代码来源:TrayIcon.cs

示例4: GeoLocationCompleted

 private void GeoLocationCompleted(IAsyncOperation<Geoposition> asyncInfo, AsyncStatus asyncStatus)
 {
     if (asyncStatus == AsyncStatus.Completed)
     {
         var deviceLocation = (Geoposition)asyncInfo.GetResults();
         try
         {
             DeviceLocation = GeoLocationAdapter.GetLocationFromDeviceGeoPositionObject(deviceLocation);
         }
         catch (Exception ex)
         {
             DeviceLocation = GeoLocationAdapter.GetDefaultLocaiton();
         }
         OnLocationLoadSuccess(new LocationEventArgs(DeviceLocation));
     }
 }
开发者ID:keyanmit,项目名称:BOWP8Client,代码行数:16,代码来源:GeoLocationFacade.cs

示例5: GeocodingCompleted

        async private void GeocodingCompleted(IAsyncOperation<MapLocationFinderResult> asyncInfo, AsyncStatus asyncStatus)
        {
            // Get the result
            MapLocationFinderResult result = asyncInfo.GetResults();

            // 
            // Update the UI thread by using the UI core dispatcher.
            // 
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // Update the status
                Status = result.Status;

                // Update th Address
                Address = result.Locations[0].Address.FormattedAddress;

                // If there are Name and/or description provided and they are not set yet, set them!
                if (Name == NameDefault && result.Locations[0].DisplayName != null && result.Locations[0].DisplayName != "") Name = result.Locations[0].DisplayName;
                if (Description == DescriptionDefault && result.Locations[0].Description != null && result.Locations[0].Description != "") Description = result.Locations[0].Description;

                // If the Name is still empty, use the Address
                if (Name == NameDefault || Name == "") Name = Address;
            });
        }
开发者ID:LdwgWffnschmdt,项目名称:CykeMaps,代码行数:24,代码来源:GeocodingLocation.cs

示例6: FindConnectionProfilesCompletedHandler

        private void FindConnectionProfilesCompletedHandler(IAsyncOperation<IReadOnlyList<ConnectionProfile>> asyncInfo, AsyncStatus asyncStatus)
        {
            if (asyncStatus == AsyncStatus.Completed)
            {
                IReadOnlyList<ConnectionProfile> connectionProfiles = asyncInfo.GetResults();
                asyncInfo.Close();

                PrintConnectionProfiles(connectionProfiles);
            }
        }
开发者ID:trilok567,项目名称:Windows-Phone,代码行数:10,代码来源:Scenario3_findconnectionprofiles.xaml.cs

示例7: GetNetworkUsageAsyncHandler

        private void GetNetworkUsageAsyncHandler(IAsyncOperation<IReadOnlyList<NetworkUsage>> asyncInfo, AsyncStatus asyncStatus)
        {
            if (asyncStatus == AsyncStatus.Completed)
            {
                try
                {
                    String outputString = string.Empty;
                    IReadOnlyList<NetworkUsage> networkUsages = asyncInfo.GetResults();

                    DateTimeOffset startTime = StartTime;

                    foreach (NetworkUsage networkUsage in networkUsages)
                    {
                        DateTimeOffset endTime = startTime + GranularityToTimeSpan(Granularity);

                        if (Granularity == DataUsageGranularity.Total)
                        {
                            endTime = EndTime;
                        }

                        outputString += PrintNetworkUsage(networkUsage, startTime, endTime);

                        startTime = endTime;
                    }

                    PrintOutputAsync(outputString);
                    PrintStatusAsync("Success");
                }
                catch (Exception ex)
                {
                    PrintErrorAsync("An unexpected error occurred: " + ex.Message);
                }
            }
            else
            {
                PrintErrorAsync("GetNetworkUsageAsync failed with message:\n" + asyncInfo.ErrorCode.Message);
            }
        }
开发者ID:ckc,项目名称:WinApp,代码行数:38,代码来源:Scenario6_networkusage.xaml.cs

示例8: GetCurrentPosition

        /// <summary>
        /// 获取用户位置后,触发本函数
        /// </summary>
        /// <param name="asyncInfo"></param>
        /// <param name="asyncStatus"></param>
        private void GetCurrentPosition(IAsyncOperation<Geoposition> asyncInfo, AsyncStatus asyncStatus)
        {
            Debug.WriteLine("获取到位置信息");
            Geoposition currentGeoposition =asyncInfo.GetResults();
            Geocoordinate coordinate= currentGeoposition.Coordinate;
            //获取的数据有偏差
            
            LatLng currentLatLng = new LatLng(coordinate.Latitude + 0.000423, coordinate.Longitude + 0.006090);
            _daBeiJing = currentLatLng;
            Debug.WriteLine(currentLatLng);
            
                if(_amap!=null)
                {
                    _amap.Dispatcher.BeginInvoke(() =>
                    {
                        _amap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(currentLatLng, 17, _bearing, _tile), 2);//移动视角(动画效果)
                        _cameraIsNew = false;
                        if (_locationMarker == null)
                        {
                            //添加圆
                            _circle = _amap.AddCircle(new AMapCircleOptions
                            {
                                Center = currentLatLng, //圆点位置
                                Radius = (float)20, //半径
                                FillColor = Color.FromArgb(80, 100, 150, 255),//圆的填充颜色
                                StrokeWidth = 1, //边框粗细
                                StrokeColor = Color.FromArgb(80, 100, 150, 255) //圆的边框颜色
                            });


                            //添加点标注,用于标注地图上的点
                            _locationMarker = _amap.AddMarker(new AMapMarkerOptions
                            {
                                Position = currentLatLng, //图标的位置
                                //待修改,更换IconUri的图标//
                                IconUri = new Uri("Images/myLocationIcon.png", UriKind.RelativeOrAbsolute), //图标的URL
                                Anchor = new Point(0.5, 0.5) //图标中心点
                            });
                        }
                        else
                        {
                            //点标注和圆的位置在当前经纬度
                            _locationMarker.Position = currentLatLng;
                            _circle.Center = currentLatLng;
                            _circle.Radius = (float)20; //圆半径
                        }
                    });
                    
                    
                }
            
            


        }
开发者ID:sduxzh,项目名称:ShareULocation,代码行数:60,代码来源:MainPage.xaml.cs

示例9: SpokenStreamCompleted

        /// <summary>
        /// The spoken stream is ready.
        /// </summary>
        private async void SpokenStreamCompleted(IAsyncOperation<SpeechSynthesisStream> asyncInfo, AsyncStatus asyncStatus)
        {
            //Debug.WriteLine("SpokenStreamCompleted");

            // Make sure to be on the UI Thread.
            var synthesisStream = asyncInfo.GetResults();
            await media.Dispatcher.RunAsync(
                            Windows.UI.Core.CoreDispatcherPriority.Normal,
                            new DispatchedHandler(() => { media.AutoPlay = true; media.SetSource(synthesisStream, synthesisStream.ContentType); media.Play(); })
            );
        }
开发者ID:slgrobotics,项目名称:Win10Bot,代码行数:14,代码来源:Speaker.cs

示例10: ReaderHasData

        private void ReaderHasData(IAsyncOperation<uint> operation, AsyncStatus target)
        {
            uint len = operation.GetResults();
            byte[] buffer = new byte[len];
            this.reader.ReadBytes(buffer);

            this.ProcessBytes(buffer, (int)len);
            DataReaderLoadOperation operation2 = this.reader.LoadAsync(256);
            operation2.Completed = new AsyncOperationCompletedHandler<uint>(this.ReaderHasData);
        }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:10,代码来源:JupiterSocket.cs

示例11: NameRecognitionCompletedHandler

        // Event handler when name recognition is completed
        private void NameRecognitionCompletedHandler(IAsyncOperation<SpeechRecognitionResult> asyncInfo, AsyncStatus asyncStatus)
        {
            isListening = false;

            var results = asyncInfo.GetResults();
            if (results.Status != SpeechRecognitionResultStatus.Success)
            {
                TextToSpeech.Speak("Sorry, I wasn't able to hear you. Try again later.");
                return;
            }

            if (results.Confidence == SpeechRecognitionConfidence.High | results.Confidence == SpeechRecognitionConfidence.Medium)
            {
                requestor = results.Text;
                if (requestor == listOfNames.First())
                {
                    if (requestedItems.Count == 0)
                    {
                        TextToSpeech.Speak("Hello" + requestor + "\n" + "The list is empty.");
                    }
                    else
                    {
                        TextToSpeech.Speak("Hello" + requestor + "\n" + "Here is the list");
                        foreach (string item in requestedItems)
                        {
                            Task.Delay(4000).Wait();
                            TextToSpeech.Speak(item);
                        }
                    }
                }
                else
                {
                    TextToSpeech.Speak("Hello" + requestor + "\n" + "What would you like for Christmas?");
                    Task.Delay(4000).Wait();
                    RecognizeChristmasListItem();
                }
            }
            else
            {
                TextToSpeech.Speak("Sorry, I do not recognize you.");
            }

        }
开发者ID:tyeth,项目名称:Christmas-List,代码行数:44,代码来源:MainPage.xaml.cs

示例12: ProcessConcreteCompletedOperation

 private void ProcessConcreteCompletedOperation(IAsyncOperation<Boolean> completedOperation, out Int64 bytesCompleted)
 {
     Boolean success = completedOperation.GetResults();
     bytesCompleted = (success ? 0 : -1);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:5,代码来源:StreamOperationAsyncResult.cs

示例13: OnPickSingleFile

        private void OnPickSingleFile(IAsyncOperation<StorageFile> info, AsyncStatus status)
        {
            var storageFile = info.GetResults();
            file = storageFile;

            storageFile.OpenReadAsync()
                .Completed = (openReadInfo, openReadStatus) =>
                    {
                        Windows.Storage.Streams.IInputStream inputStream = openReadInfo.GetResults();

                        System.IO.Stream stream = inputStream.AsStreamForRead();
                        System.IO.StreamReader reader = new StreamReader(stream);

                        this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            txtbox.Text = reader.ReadToEnd());
                    };
        }
开发者ID:julid29,项目名称:confsamples,代码行数:17,代码来源:MainPage.xaml.cs

示例14: Recognition_Completed

        /// <summary>
        /// Speech recognition completed.
        /// </summary>
        private async void Recognition_Completed(IAsyncOperation<SpeechRecognitionResult> asyncInfo, AsyncStatus asyncStatus)
        {
            var results = asyncInfo.GetResults();

            if (results.Confidence != SpeechRecognitionConfidence.Rejected)
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new DispatchedHandler(
                    () =>
                    {
                        this.txtCortanaMessages.Text = "Je recherche : " + results.Text + "...";

                        CortanaSearchViewModel viewModel = DataContext as CortanaSearchViewModel;
                        viewModel.PropertyChanged += viewModel_PropertyChanged;
                        viewModel.LoadResults(SettingsValues.SiteUrl, results.Text, SettingsValues.LoginName, SettingsValues.Password);

                    }));
            }
            else
            {
                this.txtCortanaMessages.Text = "Désolé, je n'ai pas compris.";
            }
        }
开发者ID:Mohye77,项目名称:CortanaSharePointWin10,代码行数:25,代码来源:CortanaSearch.xaml.cs

示例15: AddMenuItemFromImage

 private void AddMenuItemFromImage(IAsyncOperation<StorageFile> asyncInfo, AsyncStatus asyncStatus)
 {
     if (asyncStatus == AsyncStatus.Completed)
     {
         StorageFile imageFile = asyncInfo.GetResults();
         radialController.Menu.Items.Add(RadialControllerMenuItem.CreateFromIcon("test", RandomAccessStreamReference.CreateFromFile(imageFile)));
     }
 }
开发者ID:Microsoft,项目名称:Windows-classic-samples,代码行数:8,代码来源:Form1.cs


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