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


C# System.Threading.ManualResetEvent.WaitOne方法代码示例

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


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

示例1: ConnectionManagerAddsNewServicesFromServiceDiscovery

        public void ConnectionManagerAddsNewServicesFromServiceDiscovery()
        {
            var manualResetEvent = new System.Threading.ManualResetEvent(false);
            var serviceUri1 = new ServiceUri() { Address = "1" };
            var serviceUri2 = new ServiceUri() { Address = "2" };
            Dictionary<ServiceUri, PerformanceStatistics> services
                = new Dictionary<ServiceUri, PerformanceStatistics>()
                {
                    {serviceUri1, new PerformanceStatistics()},
                    {serviceUri2, new PerformanceStatistics()}
                };
            var serviceDiscoveryMock = new Mock<IServiceDiscovery>(MockBehavior.Strict);
            serviceDiscoveryMock.Setup(sd => sd.GetPerformanceStatistics()).Returns(() => services).Callback(() => manualResetEvent.Set());

            var manager = new ConnectionManager(remoteService: null, listener: null,
                serviceDiscovery: serviceDiscoveryMock.Object,
                serviceDiscoveryPeriod: new TimeSpan(days: 0, hours: 0, minutes: 0, seconds: 0, milliseconds: 10));

            manualResetEvent.WaitOne();
            manager.RemoteServices.Count().ShouldBe(2);
            services.Add(new ServiceUri(), new PerformanceStatistics());
            manualResetEvent.Reset();
            manualResetEvent.WaitOne();

            manager.RemoteServices.Count().ShouldBe(3);
        }
开发者ID:pbazydlo,项目名称:bluepath,代码行数:26,代码来源:ConnectionManagerTests.cs

示例2: SendMessage_Test

        public void SendMessage_Test()
        {

            RequestMessage message = new RequestMessage()
            {

                Device = "test",
                Level = MessageLevel.High,
                Message = "test",
                Source = "unitest",
                Title = "test"
            };


            ResponseMessage resmessage = CatsAgent.SendMessage(message);

            var t1 = resmessage.Message;
            var t2 = resmessage.Result;

            Assert.IsTrue(t1.Length > 0);
            Assert.AreEqual(t2, MessageSendingResult.Succeed);


            System.Threading.ManualResetEvent hand = new System.Threading.ManualResetEvent(false);

            CatsAgent.SendMessageAsync(message, new
                 Action<ResponseMessage>((ar) => { hand.Set(); }));

            hand.WaitOne();
        }
开发者ID:felix-tien,项目名称:TechLab,代码行数:30,代码来源:CatsAgentTest.cs

示例3: Scan

        public override Task<Result> Scan(MobileBarcodeScanningOptions options)
        {
            return Task.Factory.StartNew(new Func<Result>(() =>
            {
                var scanResultResetEvent = new System.Threading.ManualResetEvent(false);

                Result result = null;

                //Navigate: /ZxingSharp.WindowsPhone;component/Scan.xaml

                ScanPage.ScanningOptions = options;
                ScanPage.ResultFoundAction = (r) => 
                {
                    result = r;
                    scanResultResetEvent.Set();
                };

                ScanPage.UseCustomOverlay = this.UseCustomOverlay;
                ScanPage.CustomOverlay = this.CustomOverlay;
                ScanPage.TopText = TopText;
                ScanPage.BottomText = BottomText;

                Dispatcher.BeginInvoke(() =>
				{
					((Microsoft.Phone.Controls.PhoneApplicationFrame)Application.Current.RootVisual).Navigate(
						new Uri("/ZXingNetMobile;component/ScanPage.xaml", UriKind.Relative));
				});

                scanResultResetEvent.WaitOne();

                return result;
            }));            
        }
开发者ID:Binjaaa,项目名称:ZXing.Net.Mobile,代码行数:33,代码来源:MobileBarcodeScanner.cs

示例4: Scan

        public override Task<Result> Scan(MobileBarcodeScanningOptions options)
        {
            var rootFrame = RootFrame ?? Window.Current.Content as Frame ?? ((FrameworkElement) Window.Current.Content).GetFirstChildOfType<Frame>();
            var dispatcher = Dispatcher ?? Window.Current.Dispatcher;

            return Task.Factory.StartNew(new Func<Result>(() =>
            {
                var scanResultResetEvent = new System.Threading.ManualResetEvent(false);

                Result result = null;

                ScanPage.ScanningOptions = options;
                ScanPage.ResultFoundAction = (r) => 
                {
                    result = r;
                    scanResultResetEvent.Set();
                };

                ScanPage.UseCustomOverlay = this.UseCustomOverlay;
                ScanPage.CustomOverlay = this.CustomOverlay;
                ScanPage.TopText = TopText;
                ScanPage.BottomText = BottomText;

                dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootFrame.Navigate(typeof(ScanPage));
                });
                
                scanResultResetEvent.WaitOne();

                return result;
            }));            
        }
开发者ID:M3psipax,项目名称:ZXing.Net.Mobile,代码行数:33,代码来源:MobileBarcodeScanner.cs

示例5: ExecuteAndWaitForSSHCommand

		private static void ExecuteAndWaitForSSHCommand(string IPAddress,string command)
		{
			var handle = new System.Threading.ManualResetEvent(false);
			var helper = new SshCommandHelper(IPAddress, handle);
			helper.WriteSSHCommand(command, true);
			handle.WaitOne();
		}
开发者ID:tudor-olariu,项目名称:monoev3,代码行数:7,代码来源:MonoBrickAddinUtility.cs

示例6: Main

 static void Main()
 {
     System.Threading.ManualResetEvent close = new System.Threading.ManualResetEvent(false);
     SystemEvents.SessionEnding += (object sender, SessionEndingEventArgs e) =>
         close.Set();
     BaseClass();
     close.WaitOne();
 }
开发者ID:Trontor,项目名称:Class-Mouse-Countdown,代码行数:8,代码来源:Program.cs

示例7: Parse

		static void Parse()
		{
			var e = new System.Threading.ManualResetEvent(false);
			Console.WriteLine ("Parsing...");

			GlobalParseCache.BeginAddOrUpdatePaths (new[]{ srcDir }, false, (ea) => {
				Console.WriteLine ("Finished parsing. {0} files. {1} ms.", ea.FileAmount, ea.ParseDuration);
				e.Set();
			});

			e.WaitOne ();
		}
开发者ID:DinrusGroup,项目名称:D_Parser,代码行数:12,代码来源:BotanProfil.cs

示例8: RunAsync

		public async Task RunAsync ( Action act )
		{
			await Task.Run ( ( ) =>
			{
				System.Threading.ManualResetEvent evt = new System.Threading.ManualResetEvent ( false );
				m_dispatcher.BeginInvoke ( ( ) =>
				{
					act ( );
					evt.Set ( );
				} );
				evt.WaitOne ( );
			} );
		}
开发者ID:bl0rq,项目名称:Utilis,代码行数:13,代码来源:DispatcherWrapper.cs

示例9: Scan

		public override Task<Result> Scan (MobileBarcodeScanningOptions options)
		{
			return Task.Factory.StartNew(() => {

				try
				{
					var scanResultResetEvent = new System.Threading.ManualResetEvent(false);
					Result result = null;

					this.appController.InvokeOnMainThread(() => {
						// Free memory first and release resources
						if (viewController != null)
						{
							viewController.Dispose();
							viewController = null;
						}

						viewController = new ZxingCameraViewController(options, this);

						viewController.BarCodeEvent += (BarCodeEventArgs e) => {

							viewController.DismissViewController();

							result = e.BarcodeResult;
							scanResultResetEvent.Set();

						};

						viewController.Canceled += (sender, e) => {

							viewController.DismissViewController();

							scanResultResetEvent.Set();
						};

						appController.PresentViewController(viewController, true, () => { });

					});

					scanResultResetEvent.WaitOne();

					return result;
				}
				catch (Exception ex)
				{
					return null;
				}
			});

		}
开发者ID:nagyist,项目名称:mini-hacks,代码行数:50,代码来源:MobileBarcodeScanner.cs

示例10: RunUpdate

		public void RunUpdate()
		{
			var u = Updater.Instance;
			var waitHandler = new System.Threading.ManualResetEvent(false);


			u.NoUpdatesFound += (s, e) => waitHandler.Set();
			u.Error += (s, e) => waitHandler.Set();
			u.ExternalUpdateStarted += (s, e) => waitHandler.Set();
			u.UpdateCancelled += (s, e) => waitHandler.Set();

			Updater.CheckUpdateSimple();

			waitHandler.WaitOne();
		}
开发者ID:ChenJasonGit,项目名称:FSLib.App.SimpleUpdater,代码行数:15,代码来源:HiddenUiUpdateProxy.cs

示例11: Main

        static void Main(string[] args)
        {
            //Load initial settings

            Logger.Logger.Get("Runner").Message("App started");

            //Logger.Logger.Get().Message("App started");
            WorkerProcess.GetInstance().Process();

            System.Threading.ManualResetEvent _quitEvent = new System.Threading.ManualResetEvent(false);
            Console.CancelKeyPress += (sender, eArgs) => {
                _quitEvent.Set(); eArgs.Cancel = true;
            };

            _quitEvent.WaitOne();
        }
开发者ID:venugupta,项目名称:multi-threaded-worker-queue,代码行数:16,代码来源:Runner.cs

示例12: Application_Start

        protected void Application_Start()
        {
            // AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);

            // Automatically delete timed out sessions in our table.
            _reaperQuit = new System.Threading.ManualResetEvent(false);
            _reaper = new System.Threading.Thread(new System.Threading.ThreadStart(() => {
            while (!_reaperQuit.WaitOne(30000)) {
                Climoo.Session.SessionManager.GrimReaper();
            }
            }));
            _reaper.Start();

            Game.WorldData.Init();
        }
开发者ID:kayateia,项目名称:climoo,代码行数:16,代码来源:Global.asax.cs

示例13: Wait

        /// <summary>
        /// Call to wait for an event that is newer than the current known event
        /// </summary>
        /// <param name="eventId">The last known event id</param>
        /// <param name="milliseconds">The number of milliseconds to block</param>
        /// <returns>The current event id</returns>
        public long Wait(long eventId, int milliseconds)
        {
            System.Threading.ManualResetEvent mre;
            lock (m_lock)
            {
                //If a newer event has already occured, return immediately
                if (eventId != m_eventNo)
                    return m_eventNo;

                //Otherwise register this thread as waiting
                mre = new System.Threading.ManualResetEvent(false);
                m_waitQueue.Enqueue(mre);
            }

            //Wait until we are signalled or the time has elapsed
            mre.WaitOne(milliseconds, false);
            return m_eventNo;
        }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:24,代码来源:EventPollNotify.cs

示例14: AskForConnectionAsync

		internal async Task<Connection> AskForConnectionAsync()
		{
			using (var closedEvent = new System.Threading.ManualResetEvent(false))
			{
				var dialog = new ConnectionDialog();
				dialog.Closed += (sender, e) =>
				{
					closedEvent.Set();
				};
				dialog.Show();

				await Task.Run(new Action(() => closedEvent.WaitOne()));

				if (dialog.Ok ?? false)
					return dialog.Connection;
				else
					return null;
			}
		}
开发者ID:npcook,项目名称:terminal,代码行数:19,代码来源:App.xaml.cs

示例15: GetIsCertificateTrusted

		public bool GetIsCertificateTrusted (string uri, string certificateFingerprint)
		{
			bool value;
			
			if (!TrustedCertificates.TryGetValue (certificateFingerprint, out value)) {
				using (var handle = new System.Threading.ManualResetEvent (false)) {
					Gtk.Application.Invoke (delegate {
						value = MessageService.AskQuestion (
							"Untrusted HTTP certificate detected",
							string.Format ("Do you want to temporarily trust this certificate in order to" +
							" connect to the server at {0}?", uri),
							AlertButton.Yes, AlertButton.No) == AlertButton.Yes;
						TrustedCertificates [certificateFingerprint] = value;
						handle.Set ();
					});
					handle.WaitOne ();
				}
			}

			return value;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:21,代码来源:DefaultWebCertificateProvider.cs


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