• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAsyncOperation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAsyncOperation的典型用法代码示例。如果您正苦于以下问题:C# IAsyncOperation类的具体用法?C# IAsyncOperation怎么用?C# IAsyncOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: AsyncOperationBitmapProvider

 public AsyncOperationBitmapProvider(IAsyncOperation<Bitmap> bitmapAsyncOperation)
 {
     m_bitmapAsyncOperation = bitmapAsyncOperation
         .AsTask()
         .ContinueWith(t => (IReadableBitmap)t.Result, TaskContinuationOptions.OnlyOnRanToCompletion|TaskContinuationOptions.ExecuteSynchronously)
         .AsAsyncOperation();
 }
开发者ID:modulexcite,项目名称:Lumia-imaging-sdk,代码行数:7,代码来源:BitmapExtensions.cs


示例2: AsyncMethodWithViewModel

 private async void AsyncMethodWithViewModel(IAsyncOperation<bool> asyncOperation, bool result, IViewModel viewModel)
 {
     bool b = await asyncOperation;
     b.ShouldEqual(result);
     ViewModel = viewModel;
     AsyncMethodInvoked = true;
 }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:SerializableAsyncOperationTest.cs


示例3: ExecuteFile

		protected void ExecuteFile (IAsyncOperation op)
		{
//			if (op.Success)
//				ProfilingOperations.Profile (profiler, doc);

			//if (op.Success)
			//	doc.Run ();
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:ProjectCommands.cs


示例4: AddOperation

 public void AddOperation(IAsyncOperation operation)
 {
     lock (list) {
         if (monitor.IsCancelRequested)
             operation.Cancel ();
         else
             list.Add (operation);
     }
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:9,代码来源:AggregatedOperationMonitor.cs


示例5: 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


示例6: 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


示例7: OperCompleted

		void OperCompleted (IAsyncOperation op)
		{
			bool raiseEvent;
			lock (operations) {
				completed++;
				success = success && op.Success;
				successWithWarnings = success && op.SuccessWithWarnings;
				raiseEvent = (completed == operations.Count);
			}
			if (raiseEvent && Completed != null)
				Completed (this);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:12,代码来源:AggregatedAsyncOperation.cs


示例8: 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


示例9: complete_failed_request

        private void complete_failed_request(Exception ex, HttpContext http, IAsyncOperation aop)
        {
            var errMsg = "ProcessRequest() failed ({0}); {1}".Fmt(http.Request.Path, ex.Message);

            if (ex is BadRequestException)
                _log.Error(errMsg);
            else
                _log.Error(ex, errMsg);

            http.set_error_response(ex.Message);

            aop.MarkAsSynchronous();
            aop.NotifyCompletion();
        }
开发者ID:Kidify,项目名称:L4p,代码行数:14,代码来源:HandleAllRequests.cs


示例10: 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


示例11: OnFileOpened

        private void OnFileOpened(IAsyncOperation op)
        {
            if (!op.Success) return;

            IMember member = CurrentNode.DataItem as IMember;
            int line = member.Region.BeginLine;
            string file = GetFileName ();

            IWorkbenchWindow window = Runtime.FileService.GetOpenFile (file);
            if (window == null) {
                return;
            }

            IViewContent content = window.ViewContent;
            if (content is IPositionable) {
                ((IPositionable)content).JumpTo (Math.Max (1, line), 1);
            }
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:18,代码来源:MemberNodeCommandHandler.cs


示例12: 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


示例13: Clean

		public IAsyncOperation Clean (IBuildTarget entry)
		{
			if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation;
			
			ITimeTracker tt = Counters.BuildItemTimer.BeginTiming ("Cleaning " + entry.Name);
			try {
				IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetCleanProgressMonitor ();
				OnStartClean (monitor, tt);
				DispatchService.ThreadDispatch (() => CleanAsync (entry, monitor, tt, false));
				
				currentBuildOperation = monitor.AsyncOperation;
				currentBuildOperationOwner = entry;
				currentBuildOperation.Completed += delegate {
					currentBuildOperationOwner = null;
				};
			}
			catch {
				tt.End ();
				throw;
			}
			
			return currentBuildOperation;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:23,代码来源:ProjectOperations.cs


示例14: Execute

		public IAsyncOperation Execute (IBuildTarget entry, ExecutionContext context)
		{
			if (currentRunOperation != null && !currentRunOperation.IsCompleted) return currentRunOperation;

			NullProgressMonitor monitor = new NullProgressMonitor ();

			DispatchService.ThreadDispatch (delegate {
				ExecuteSolutionItemAsync (monitor, entry, context);
			});
			currentRunOperation = monitor.AsyncOperation;
			currentRunOperationOwner = entry;
			currentRunOperation.Completed += delegate {
			 	DispatchService.GuiDispatch (() => {
					var error = monitor.Errors.FirstOrDefault ();
					if (error != null)
						IdeApp.Workbench.StatusBar.ShowError (error.Message);
					currentRunOperationOwner = null;
				});
			};
			return currentRunOperation;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:21,代码来源:ProjectOperations.cs


示例15: Build

//		bool errorPadInitialized = false;
		public IAsyncOperation Build (IBuildTarget entry)
		{
			if (currentBuildOperation != null && !currentBuildOperation.IsCompleted) return currentBuildOperation;
			/*
			if (!errorPadInitialized) {
				try {
					Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
					errorsPad.Window.PadHidden += delegate {
						content.IsOpenedAutomatically = false;
					};
					
					Pad monitorPad = IdeApp.Workbench.Pads.FirstOrDefault (pad => pad.Content == ((OutputProgressMonitor)((AggregatedProgressMonitor)monitor).MasterMonitor).OutputPad);
					monitorPad.Window.PadHidden += delegate {
						monitorPad.IsOpenedAutomatically = false;
					};
				} finally {
					errorPadInitialized = true;
				}
			}
			*/
			
			ITimeTracker tt = Counters.BuildItemTimer.BeginTiming ("Building " + entry.Name);
			try {
				IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetBuildProgressMonitor ();
				BeginBuild (monitor, tt, false);
				DispatchService.ThreadDispatch (() => BuildSolutionItemAsync (entry, monitor, tt));
				currentBuildOperation = monitor.AsyncOperation;
				currentBuildOperationOwner = entry;
				currentBuildOperation.Completed += delegate { currentBuildOperationOwner = null; };
			} catch {
				tt.End ();
				throw;
			}
			return currentBuildOperation;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:36,代码来源:ProjectOperations.cs


示例16: showPopup

        public async static Task<bool> showPopup(string message, bool errorServer = false)
        {
            // Close the previous one out
            if (messageDialogCommand != null)
            {
                messageDialogCommand.Cancel();
                messageDialogCommand = null;
            }

            MessageDialog dlg = new MessageDialog(message);

            if (errorServer)
            {
                dlg.Commands.Clear();
                dlg.Commands.Add(new UICommand("Retry"));
                dlg.Commands.Add(new UICommand("Cancel"));
            }

            messageDialogCommand = dlg.ShowAsync();
            var res = await messageDialogCommand;

            if (errorServer && res.Label == "Retry")
                return false;
            return true;
        }
开发者ID:speakproject,项目名称:windowsphone,代码行数:25,代码来源:MainPage.xaml.cs


示例17: OnButtonClick

        async void OnButtonClick(object sender, RoutedEventArgs e) {
            MessageDialog msgdlg = new MessageDialog("Choose a color", "How to Async #1");
            msgdlg.Commands.Add(new UICommand("Red", null, Colors.Red));
            msgdlg.Commands.Add(new UICommand("Green", null, Colors.Green));
            msgdlg.Commands.Add(new UICommand("Blue", null, Colors.Blue));

            // Start a five-second timer
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(5);
            timer.Tick += OnTimerTick;
            timer.Start();

            // Show the MessageDialog
            asyncOp = msgdlg.ShowAsync();
            IUICommand command = null;

            try {
                command = await asyncOp;
            }
            catch (Exception) {
                // The exception in this case will be TaskCanceledException
            }

            // Stop the timer
            timer.Stop();

            // If the operation was canceled, exit the method
            if (command == null) {
                return;
            }

            // Get the Color value and set the background brush
            Color clr = (Color)command.Id;
            contentGrid.Background = new SolidColorBrush(clr);
        }
开发者ID:ronlemire2,项目名称:UWP-Testers,代码行数:35,代码来源:HowToCancelAsyncPage.xaml.cs


示例18: Load

		void Load ()
		{
			var monitor = loadMonitor;
			System.Threading.ThreadPool.QueueUserWorkItem (delegate {
				try {
					HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create (url);
					WebResponse resp = req.GetResponse ();
					MemoryStream ms = new MemoryStream ();
					using (var s = resp.GetResponseStream ()) {
						s.CopyTo (ms);
					}
					var data = ms.ToArray ();

					MonoDevelop.Ide.DispatchService.GuiSyncDispatch (delegate {
						Gdk.PixbufLoader l = new Gdk.PixbufLoader (resp.ContentType);
						l.Write (data);
						image = l.Pixbuf;
						l.Close ();
						monitor.Dispose ();
					});
					
					// Replace the async operation to avoid holding references to all
					// objects that subscribed the Completed event.
					loadOperation = NullAsyncOperation.Success;
				} catch (Exception ex) {
					loadMonitor.ReportError (null, ex);
					Gtk.Application.Invoke (delegate {
						monitor.Dispose ();
					});
					loadOperation = NullAsyncOperation.Failure;
				}
				loadMonitor = null;
			});
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:34,代码来源:ImageLoader.cs


示例19: Show

        /// <summary>
        /// Shows the dialog. It takes <see cref="SystemDialogViewModel"/> to populate the system dialog. It also sets the first command to be 
        /// the default and last one to be the cancel command.
        /// </summary>
        /// <param name="viewType"> Type of dialog control. </param>
        public async void Show(Type viewType)
        {
            this.Initialize(); 

            var dialog = new MessageDialog(ViewModel.ActivationData.Message, ViewModel.ActivationData.Title);
            foreach (var command in ViewModel.ActivationData.Commands)
            {
                dialog.Commands.Add(new UICommand(command));
            }

            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex = (uint)ViewModel.ActivationData.Commands.Length - 1;

            try
            {
                this.dialogTask = dialog.ShowAsync();
                var result = await this.dialogTask;

                this.dialogTask = null;
                this.NavigationService.GoBack(result.Label);
            }
            catch (TaskCanceledException ex)
            {
                // Happens when you call nanavigationSerivce.GoBack(...) while the dialog is still open.
            }
        }
开发者ID:bezysoftware,项目名称:MVVM-Dialogs,代码行数:31,代码来源:SystemDialogContainer.cs


示例20: Exception

        /// <summary>
        /// 语音识别
        /// </summary>
        /// <returns>识别文本</returns>
        public async Task<string> RecognizeAsync()
        {
            if (_initialization == null || _initialization.IsFaulted)
                _initialization = InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);

            await _initialization;

            CancelRecognitionOperation();

            // Start recognition.
            try
            {
                _recognitionOperation = _speechRecognizer.RecognizeWithUIAsync();
                SpeechRecognitionResult speechRecognitionResult = await _recognitionOperation;
                // If successful, return the recognition result.
                if (speechRecognitionResult.Status == SpeechRecognitionResultStatus.Success)
                    return speechRecognitionResult.Text;
                else
                    throw new Exception($"Speech recognition failed. Status: {speechRecognitionResult.Status}");
            }
            catch (Exception ex) when ((uint)ex.HResult == HResultPrivacyStatementDeclined)
            {
                // Handle the speech privacy policy error.
                var messageDialog = new MessageDialog("您没有同意语音识别隐私声明,请同意后重试");
                await messageDialog.ShowAsync();
                throw;
            }
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:32,代码来源:SpeechService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAsyncResult类代码示例发布时间:2022-05-24
下一篇:
C# IAsyncDocumentSession类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap