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


C# Threading.ManualResetEvent类代码示例

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


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

示例1: DbThreadsGator

 public DbThreadsGator(bool gateIsOpen)
 {
     if (gateIsOpen)
         gate = new System.Threading.ManualResetEvent(true);
     else
         gate = new System.Threading.ManualResetEvent(false);
 }
开发者ID:hhblaze,项目名称:DBreeze,代码行数:7,代码来源:DbThreadsGator.cs

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

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

        public ADTFile(WDTFile wdt, string fileName, uint indexX, uint indexY, bool initial = false)
        {
            bool unkFlag = (wdt.Flags & 0x84) != 0;
            if (unkFlag)
                throw new Exception();

            IndexX = indexX;
            IndexY = indexY;
            FileName = fileName;
            mLoadEvent = new System.Threading.ManualResetEvent(false);
            if (initial == false)
            {
                Game.GameManager.ThreadManager.LaunchThread(
                    () =>
                    {
                        try
                        {
                            AsyncLoadProc();
                        }
                        catch (Exception)
                        {
                        }
                    }
                );
            }
            else
                AsyncLoadProc();

            ADTManager.AddADT(this);
        }
开发者ID:remixod,项目名称:sharpwow,代码行数:30,代码来源:ADTFile.cs

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

示例6: RunItems

 private void RunItems(List<WaitItem> waitItems)
 {
     try
     {
         System.Threading.ManualResetEvent[] mre = new System.Threading.ManualResetEvent[waitItems.Count];
         for (int i = 0; i < waitItems.Count; i++)
         {
             mre[i] = waitItems[i].MRE;
         }
         foreach (WaitItem item in waitItems)
         {
             item.MRE.Reset();
             System.Threading.ThreadPool.QueueUserWorkItem(ThreadExecute, item);
         }
         System.Threading.WaitHandle.WaitAll(mre);
         foreach (WaitItem item in waitItems)
         {
             if (item.Error != null)
                 throw item.Error;
         }
     }
     finally
     {
         foreach (WaitItem item in waitItems)
         {
             Push(item);
         }
         waitItems.Clear();
     }
 }
开发者ID:priceLiu,项目名称:IntegrationTest,代码行数:30,代码来源:MultiThreadTest.cs

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

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

示例9: AgentThreadInfo

			public AgentThreadInfo(System.Threading.Thread thread) {
				if (object.ReferenceEquals(thread, null)) { throw new ArgumentNullException("thread"); }

				this.Thread = thread;
				this.MainReset = new System.Threading.ManualResetEvent(false);
				this.AgentReset = new System.Threading.ManualResetEvent(false);
			}
开发者ID:TenCoKaciStromy,项目名称:TcKs.Gr1dRuntime,代码行数:7,代码来源:World.cs

示例10: NetzService

		public NetzService(string[] args)
		{
			this.args = args;
			resetEvent = new System.Threading.ManualResetEvent(false);
			ServiceName = ProjectInstaller.SERVICENAME;
			Init();
		}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-msnet-netz-compressor-madebits,代码行数:7,代码来源:Service.cs

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

示例12: Control

 public Control(string ServerAddress, int Port)
 {
     log = new Logger(AppInfo.Title + Port);
     m_sServerAddress = ServerAddress;
     m_iPort = Port;
     m_TCPClient = new System.Net.Sockets.TcpClient();
     m_EventChannelConnectionComplete = new System.Threading.ManualResetEvent(false);
     m_sLastError = "";
     m_EventReceivedFile = new System.Threading.AutoResetEvent(false);
 }
开发者ID:CarverLab,项目名称:Oyster,代码行数:10,代码来源:Control.cs

示例13: PeriodicOutput

 public PeriodicOutput(ConsoleOutput messageSink, TimeSpan updateFrequency)
 {
     m_output = messageSink;
     m_readyEvent = new System.Threading.ManualResetEvent(false);
     m_finishEvent = new System.Threading.ManualResetEvent(false);
     m_updateFrequency = updateFrequency;
     m_thread = new System.Threading.Thread(this.ThreadMain);
     m_thread.IsBackground = true;
     m_thread.Name = "Periodic console writer";
     m_thread.Start();
 }
开发者ID:Xelio,项目名称:duplicati,代码行数:11,代码来源:Commands.cs

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

示例15: CommandItem

        internal bool m_UpdateRequired { get; set; } //true if this command updates a polled status variable, and an update is needed ASAP

        /// <summary>
        /// 
        /// </summary>
        /// <param name="command">actual serial command to be sent, not including ending '#' or the native checksum</param>
        /// <param name="timeout">timeout value for this command in msec, -1 if no timeout wanted</param>
        /// <param name="wantResult">does the caller want the result returned by Gemini?</param>
        /// <param name="bRaw">command is a raw string to be passed to the device unmodified</param>
        internal CommandItem(string command, int timeout, bool wantResult, bool bRaw)
        {
            m_Command = command;
            m_ThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;
            m_Timeout = timeout;

            // create a wait handle if result is desired
            if (wantResult)
                m_WaitForResultHandle = new System.Threading.ManualResetEvent(false);
            m_Result = null;
            m_Raw = bRaw;
        }
开发者ID:PKAstro,项目名称:Ascom.Gemini.Telescope,代码行数:21,代码来源:CommandItem.cs


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