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


C# EventWaitHandle.Reset方法代码示例

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


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

示例1: ChangeCollection

 public void ChangeCollection()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableDictionary<int, string>();
   test.Changed += Dictionary_Changed;
   test.Add(0, "myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Add() is not recognized as a change");
   _handle.Reset();
   test[0] = "newValue";
   Assert.IsTrue(_handle.WaitOne(10), "this[] is not recognized as a change");
   _handle.Reset();
   test.Remove(0);
   Assert.IsTrue(_handle.WaitOne(10), "Remove() is not recognized as a change");
 }
开发者ID:rnpowerconsulting,项目名称:appstract,代码行数:14,代码来源:ObservableDictionaryTests.cs

示例2: Execute

        public override bool Execute()
        {
            try
            {
                syncEventName = new TaskItem(Guid.NewGuid().ToString());
                
                handle = new EventWaitHandle(false, EventResetMode.ManualReset, syncEventName.ItemSpec);
                handle.Reset();

                threadLock = GetLock(lockName);

                new Thread(new ThreadStart(AsyncExecute)).Start();

                while (m_AsyncThreadState == ThreadState.NOT_STARTED)
                {
                    Thread.Sleep(500);
                }
                
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    Log.LogErrorFromException(e);
                }
                catch { }
                return false;
            }
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:30,代码来源:AsyncExecBuildTask.cs

示例3: Controller

 public Controller(BlockingMediator mediator)
 {
     _signal = new AutoResetEvent(false);
     mediator.AddSignal(_signal);
     dynamic config = ConfigurationManager.GetSection("delays");
     var delays = new Dictionary<MessageType, int>();
     foreach (string name in config)
     {
         delays[Hearts.Utility.Enum.Parse<MessageType>(name)] =
             int.Parse(config[name]);
     }
     foreach (var type in Hearts.Utility.Enum.GetValues<MessageType>())
     {
         var key = type;
         mediator.Subscribe(type, ignore =>
             {
                 if (delays.ContainsKey(key))
                 {
                     Thread.Sleep(delays[key]);
                 }
                 _signal.Reset();
                 if (!IsBlocking)
                 {
                     ThreadPool.QueueUserWorkItem(_ => _signal.Set());
                 }
             });
     }
 }
开发者ID:sdevlin,项目名称:clarity-hearts,代码行数:28,代码来源:Controller.cs

示例4: CrashTestOnMerge

        public void CrashTestOnMerge()
        {
            string path = Path.GetFullPath ("TestData\\CrashTestOnMerge");
            using (var db = new KeyValueStore(path)) db.Truncate ();

            var doneSetting = new EventWaitHandle (false, EventResetMode.ManualReset, "CrashTestOnMerge");
            doneSetting.Reset ();

            string testPath = Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().GetName ().CodeBase), "RazorTest.exe");
            var process = Process.Start (testPath, "CrashTestOnMerge");

            doneSetting.WaitOne (30000);
            process.Kill ();
            process.WaitForExit ();

            // Open the database created by the other program
            using (var db = new KeyValueStore(path)) {
                db.Manifest.Logger = (msg) => Console.WriteLine (msg);

                Console.WriteLine ("Begin enumeration.");
                ByteArray lastKey = new ByteArray ();
                int ct = 0;
                foreach (var pair in db.Enumerate()) {
                    ByteArray k = new ByteArray (pair.Key);
                    Assert.True (lastKey.CompareTo (k) < 0);
                    lastKey = k;
                    ct++;
                }
                Assert.AreEqual (50000, ct);
                Console.WriteLine ("Found {0} items in the crashed database.", ct);
            }
        }
开发者ID:T145,项目名称:razordbx,代码行数:32,代码来源:CrashTests.cs

示例5: Main

        public static void Main()
        {
            // 1. 로그헬퍼 환경설정 읽기 - 클라이언트에서 xml파일로 환경설정 읽기
            LogHelper.XMLConfiguratorLoader.Loader("LogHelperXMLConfigure.txt");
            // 2. 프로그램 버전 설정
            LogHelper.XMLConfiguratorLoader.ProgramVersion = "1.0.0.0";

            // 3. 기본LogHelper를 등록 한다.
            LogHelper.LogHelper.AddLogHelper(LogHelperType.Default, "사용자 아이디");

            _ewh = new EventWaitHandle(false, EventResetMode.AutoReset);
            Console.WriteLine("동기화 처리된 스레드 시작");

            Thread T1 = new Thread(
                    new ThreadStart(ThreadProc1)
                );
            T1.Start();
            _ewh.WaitOne();

            Thread T2 = new Thread(
                    new ThreadStart(ThreadProc2)
                );
            T2.Start();
            _ewh.WaitOne();
            _ewh.Reset();
        }
开发者ID:tyeom,项目名称:LogHelper,代码行数:26,代码来源:Program.cs

示例6: GetNextMove_Impl

        protected override IMove GetNextMove_Impl(IGameBoard board)
        {
            m_GameBoard = board as GameBoard;
            InkCollectorStrokeEventHandler handler = new InkCollectorStrokeEventHandler(m_InkPicture_Stroke);
            IMove move = null;

            m_Waiter = new EventWaitHandle(false, EventResetMode.ManualReset);
            m_InkPicture.Stroke += handler;

            try
            {
                while (move == null)
                {
                    m_Waiter.Reset();
                    if (m_Waiter.WaitOne())
                    {
                        move = m_Move;
                    }
                }
            }
            finally
            {
                m_InkPicture.Stroke -= handler;
            }

            return move;
        }
开发者ID:bubbafat,项目名称:Dots-and-Boxes-Game,代码行数:27,代码来源:InkInputPlayer.cs

示例7: AsyncLookupCustomerSetsCustomerName

        public void AsyncLookupCustomerSetsCustomerName()
        {
            string ruleSet = "Lookup";
              var actual = RuleBaseClassesRoot.NewEditableRoot(ruleSet);

              var waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
              actual.ValidationComplete += (o, e) => waitHandle.Set();
              waitHandle.Reset();
              actual.CustomerId = 1;
              waitHandle.WaitOne();  // wait for async lookup to complete
              Assert.AreEqual("Rocky Lhotka", actual.Name);

              waitHandle.Reset();
              actual.CustomerId = 2;
              waitHandle.WaitOne();
              Assert.AreEqual("Customer_2", actual.Name);
        }
开发者ID:BiYiTuan,项目名称:csla,代码行数:17,代码来源:RuleBaseClassesTests.cs

示例8: LoadQuestionsData

        public void LoadQuestionsData(IList<Uri> addresses, bool IsTruncateTempDB = true)
        {

            WebHttpCrawlerClient client = new WebHttpCrawlerClient();

            client.SetRequestDetail = (x) =>
            {
                x._HttpWebRequest.AutomaticDecompression = DecompressionMethods.GZip;
                x._HttpWebRequest.Referer = "https://api.stackexchange.com/docs/questions";
            };

            WebThreadDesigation t = new WebThreadDesigation(client);
            t.EventWaitHandleName = "WebThreadDesigation";

            StackoverflowPageAnalysis ana = new StackoverflowPageAnalysis();
            AnalysisThreadDesigation<QuestionInfo> a = new AnalysisThreadDesigation<QuestionInfo>(ana);
            a.EventWaitHandleName = "StackoverflowPageAnalysis";
            DBThreadDesigation d = new DBThreadDesigation();
            d.EventWaitHandleName = "DBThreadDesigation";
            CrawlerSyncObject syscobject = new CrawlerSyncObject();
            AnalysisSyncObject anasissyncObject = new AnalysisSyncObject();

            SendImformation infos = new SendImformation();
            infos.ConnectString = "data source=CIA-SH-svr-sis;initial catalog=stackoverflowNew;integrated security=True;";

            infos.EventhandlerName = "QuestionTemp1_Tinct";
            infos.DestinationtableName = "QuestionTemp1_Tinct";
            infos.IsWantToMerged = false;
            infos.MergeSQlSPName = "";

            EventWaitHandle eventWaitHandle1 = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, t.EventWaitHandleName);
            eventWaitHandle1.Reset();
            EventWaitHandle eventWaitHandle2 = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, a.EventWaitHandleName);
            eventWaitHandle2.Reset();
            EventWaitHandle eventWaitHandle3 = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, d.EventWaitHandleName);
            eventWaitHandle3.Reset();
            EventWaitHandle eventWaitHandle4 = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, infos.EventhandlerName);
            eventWaitHandle4.Reset();
            Task.Run(() => { t.CrawlerUris(addresses, 10, syscobject); });
            Task.Run(() => { a.AnalysisResults(t.resultlists, 5, syscobject, anasissyncObject); });
            Task.Run(() =>
            {
                d.SendDispatchDatas<QuestionInfo>(ref a.datas, 500, ref anasissyncObject, infos,
                    null);
            });
            eventWaitHandle1.WaitOne();
            eventWaitHandle2.WaitOne();
            eventWaitHandle3.WaitOne();
            eventWaitHandle4.WaitOne();
        }
开发者ID:misun-ms,项目名称:TinctV2,代码行数:50,代码来源:StackoverflowControllercs.cs

示例9: TryDo

        static void TryDo(Action action, int timeout)
        {
            var waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            {
                AsyncCallback callback = ar => waitHandle.Set();
                action.BeginInvoke(callback, null);

                if (!waitHandle.WaitOne(timeout))
                {
                    waitHandle.Reset();
                    throw new TimeoutException("Failed to complete in the timeout specified.");
                }
            }
        }
开发者ID:PoppermostProductions,项目名称:Embedded-Mono-Sample,代码行数:15,代码来源:EntryPoint.cs

示例10: Reset

 public void Reset()
 {
     _ready.Reset();
     _start.Reset();
     _start.Reset();
     for( int i=0; i < 100; i++ )
     {
         using (EventWaitHandle handle = new EventWaitHandle(false, EventResetMode.ManualReset, _signal + ".ready" + i))
         {
             if (handle.WaitOne(0, false))
                 handle.Reset();
             else
                 break;
         }
     }
 }
开发者ID:TijW,项目名称:protobuf-csharp-rpc,代码行数:16,代码来源:TestSignals.cs

示例11: Learn

        public void Learn()
        {
            ewh=new EventWaitHandle(false,EventResetMode.AutoReset);

            for (int i = 0; i <=4; i++)
            {
                Thread t=new Thread(new ParameterizedThreadStart(ThreadProc));
                t.Start(i);
            }

            while (Interlocked.Read(ref threadCount)<5)
            {
                Thread.Sleep(500);
            }

            while (Interlocked.Read(ref threadCount)>0)
            {
                Console.WriteLine("Press Enter to release a waiting thread.");
                Console.ReadLine();
                clearCount.Set();
                WaitHandle.SignalAndWait(ewh, clearCount);
                Console.WriteLine("loop again.");
            }
            Console.WriteLine();

            ewh=new EventWaitHandle(false,EventResetMode.ManualReset);

            for (int i = 0; i <=4; i++)
            {
                Thread t=new Thread(new ParameterizedThreadStart(ThreadProc));
                t.Start(i);
            }

            while (Interlocked.Read(ref threadCount)<5)
            {
                Thread.Sleep(500);
            }

            Console.WriteLine("Press ENTER to release the waiting threads");
            Console.ReadLine();
            ewh.Set();
            ewh.Reset();
            Console.WriteLine("Press ENTER to release the waiting threads");
            Console.ReadLine();
            ewh.Set();
        }
开发者ID:dmgactive,项目名称:cslearn,代码行数:46,代码来源:SingalWait.cs

示例12: Main

        static void Main(string[] args)
        {
            Server _server = null;
            Application _application = null;            
            Query _results;
            //InputAdapter Config 
                InputConfig _inputConfig = new InputConfig();


                string _stopSignalName = "TimeToStop";                
                EventWaitHandle _adapterStopSignal = new EventWaitHandle(false, EventResetMode.ManualReset, _stopSignalName);                

                try
                {

                    // Creating the server and application
                    _server = Server.Create("localhost");
                    _application = _server.CreateApplication("TwitterStream");                    
                    var input = CepStream<TweetsType>.Create("TwitterInputStream", typeof(InputFactory), _inputConfig, EventShape.Point);

                    var query1 = from s in input
                                 group s by s.HashTag into grp
                                 from win in grp.TumblingWindow(TimeSpan.FromSeconds(10), HoppingWindowOutputPolicy.ClipToWindowEnd)
                                 select new
                                 {
                                     HashTag = grp.Key,
                                     cnt = win.Count()
                                 };
                    _results = query1.ToQuery(_application, "TweetsCount", "Data Query2", typeof(TotalCountOutputFactory),
                                          _stopSignalName,
                                          EventShape.Point,
                                          StreamEventOrder.FullyOrdered);
                    _adapterStopSignal.Reset();                    
                    //Start the Query                
                    _results.Start();
                    //_results2.Start();                    
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                }
        }
开发者ID:EdenBarnett,项目名称:Disease-Monitor-System,代码行数:43,代码来源:Program.cs

示例13: PingPong

        public void PingPong(EventResetMode mode)
        {
            // Create names for the two events
            string outboundName = Guid.NewGuid().ToString("N");
            string inboundName = Guid.NewGuid().ToString("N");

            // Create the two events and the other process with which to synchronize
            using (var inbound = new EventWaitHandle(true, mode, inboundName))
            using (var outbound = new EventWaitHandle(false, mode, outboundName))
            using (var remote = RemoteInvoke(PingPong_OtherProcess, mode.ToString(), outboundName, inboundName))
            {
                // Repeatedly wait for one event and then set the other
                for (int i = 0; i < 10; i++)
                {
                    Assert.True(inbound.WaitOne(FailWaitTimeoutMilliseconds));
                    if (mode == EventResetMode.ManualReset)
                    {
                        inbound.Reset();
                    }
                    outbound.Set();
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:23,代码来源:EventWaitHandleTests.cs

示例14: Main

        static void Main(string[] args)
        {
            Server _server = null;
            Application _application = null;            
            Query _results, _results2;
            //InputAdapter Config 
                InputConfig _inputConfig = new InputConfig();


                string _stopSignalName = "TimeToStop";                
                EventWaitHandle _adapterStopSignal = new EventWaitHandle(false, EventResetMode.ManualReset, _stopSignalName);                

                try
                {

                    // Creating the server and application
                    _server = Server.Create("localhost");
                    _application = _server.CreateApplication("TwitterStream");                    
                    var input = CepStream<TweetsType>.Create("TwitterInputStream", typeof(InputFactory), _inputConfig, EventShape.Point);                    

                    var query1 = from e in input
                                 select new { text = e.Text, createdAt = e.CreatedAt, location=e.Location, lang=e.Lang, tweetid=e.TweetID, followercnt=e.FollowersCount, friendscnt=e.FriendsCount, hash = e.HashTag, userName = e.UserName, timeZone=e.TimeZone, lat = e.Latitude, lon = e.Longitude };

                    _results = query1.ToQuery(_application, "TweetsData", "Data Query", typeof(OutputFactory),
                                          _stopSignalName,
                                          EventShape.Point,
                                          StreamEventOrder.FullyOrdered);
                    _adapterStopSignal.Reset();                    
                    //Start the Query                
                    _results.Start();                    
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                }
        }
开发者ID:EdenBarnett,项目名称:Disease-Monitor-System,代码行数:37,代码来源:Program.cs

示例15: WaitOnEvent

        /// <summary>
        /// Waits on 'waitEvent' with a timeout of 'millisceondsTimeout.  
        /// Before the wait 'numWaiters' is incremented and is restored before leaving this routine.
        /// </summary>
        bool WaitOnEvent(EventWaitHandle waitEvent, ref uint numWaiters, int millisecondsTimeout)
        {
            Debug.Assert (MyLockHeld);

            waitEvent.Reset ();
            numWaiters++;

            bool waitSuccessful = false;

            // Do the wait outside of any lock
            ExitMyLock();
            try {
                waitSuccessful = waitEvent.WaitOne (millisecondsTimeout, false);
            } finally {
                EnterMyLock ();
                --numWaiters;
                if (!waitSuccessful)
                    ExitMyLock ();
            }
            return waitSuccessful;
        }
开发者ID:vietnt,项目名称:xsp,代码行数:25,代码来源:ReaderWriterLockSlim.cs


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