Exemple #1
0
        private void _4()
        {
            //Probably equivalent like _2()
            WaitDelegate wd = Wait;
            IAsyncResult ar = wd.BeginInvoke(3000, null, null);

            while (ar.AsyncWaitHandle.WaitOne(50, true)) /* waiting */ } {
 public void WaitConnectionAsync()
 {
     if (connectState == ConnectState.born)
     {
         connectState = ConnectState.waitingConnection;
         waitDelegate.BeginInvoke(null, null);
     }
 }
Exemple #3
0
        //Global variable for example _3 - not necessery (see third parameter BeginInvoke in _3)
        //private WaitDelegate wd;

        private void _3()
        {
            WaitDelegate wd = Wait;
            //Equivalent, but parameters are seen
            //AsyncCallback ac = new AsyncCallback(WaitCallback)

            //Is properly passing delegate instance like third (object) parameter
            IAsyncResult ar = wd.BeginInvoke(1000, WaitCallback, wd);
        }
 public void WaitConnectionAsync()
 {
     if (connectState == ConnectState.born)
     {
         connectState = ConnectState.waitingConnection;
         Console.WriteLine("名前付きパイプ:接続待ち開始");
         waitDelegate.BeginInvoke(null, null);
     }
 }
Exemple #5
0
        /// <summary>
        /// Waits for millis milliseconds
        /// </summary>
        /// <param name="millis"></param>
        public void wait(int millis)
        {
            Wait         wait = new Wait();
            WaitDelegate wDel = new WaitDelegate(wait.waitFor);

            System.Console.WriteLine("CALLING WAIT " + millis);
            isSleep = true;
            wDel.BeginInvoke(millis, new AsyncCallback(CallBackMethod), wDel);
        }
Exemple #6
0
        public void sendRoomData(ConnectedUser User)
        {
            WaitDelegate X  = new WaitDelegate(sendRoomData2);
            IAsyncResult ar = X.BeginInvoke(User, null, null);

            ar.AsyncWaitHandle.WaitOne(1000, false);
            if (ar.IsCompleted)
            {
                X.EndInvoke(ar);
            }
        }
Exemple #7
0
        private void _2()
        {
            //Cyclic polling
            WaitDelegate wd = Wait;
            IAsyncResult ar = wd.BeginInvoke(2000, null, null);

            //Running
            while (!ar.IsCompleted)
            {
                Console.WriteLine("!ar.IsCompleted");
                Thread.Sleep(100);
            }

            //Get result
            int res = wd.EndInvoke(ar);

            Console.WriteLine(res);

            //If the main process is terminated, so subprocess is terminate too
        }
Exemple #8
0
 public void sendRoomData(ConnectedUser User)
 {
     WaitDelegate X = new WaitDelegate(sendRoomData2);
     IAsyncResult ar = X.BeginInvoke(User, null, null);
     ar.AsyncWaitHandle.WaitOne(1000, false);
     if (ar.IsCompleted)
     {
         X.EndInvoke(ar);
     }
 }
Exemple #9
0
 /// <summary>
 /// Waits for millis milliseconds
 /// </summary>
 /// <param name="millis"></param>
 public void wait(int millis)
 {
     Wait wait = new Wait();
     WaitDelegate wDel = new WaitDelegate(wait.waitFor);
     System.Console.WriteLine("CALLING WAIT " + millis);
     isSleep = true;
     wDel.BeginInvoke(millis, new AsyncCallback(CallBackMethod), wDel);
 }