コード例 #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 */ } {
コード例 #2
0
ファイル: DynamicEval.cs プロジェクト: ndrarmstrong/ece150
        /// <summary>
        /// Initializes a new instance of the DynamicEval class.
        /// </summary>
        /// <param name="highlightDelegate">An implementation of the 'Highlight' function.</param>
        /// <param name="highlightBoxDelegate">An implementation of the 'HighlightBox' function.</param>
        /// <param name="waitDelegate">An implementation of the 'Wait' function.</param>
        public DynamicEval(HighlightDelegate highlightDelegate, HighlightBoxDelegate highlightBoxDelegate, WaitDelegate waitDelegate)
        {
            this.highlightDelegate    = highlightDelegate;
            this.highlightBoxDelegate = highlightBoxDelegate;
            this.waitDelegate         = waitDelegate;

            this.Initialize();
        }
コード例 #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);
        }
コード例 #4
0
 public WaitWindow(Window owner, string title, WaitDelegate waitAction, object threadParameter)
 {
     InitializeComponent();
     Title = title;
     WaitInfoTextBlock.Text = title;
     WaitAction             = waitAction;
     Owner           = owner;
     ThreadParameter = threadParameter;
 }
コード例 #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);
        }
コード例 #6
0
ファイル: Room.cs プロジェクト: djdeathgirl/Jabbo
        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);
            }
        }
コード例 #7
0
        public void WaitForCondition(WaitDelegate waitDelegate, int msecTimeout = 500)
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromMilliseconds(msecTimeout));

            wait.Until(
                (d) =>
            {
                try
                {
                    return(waitDelegate(d));
                }
                catch
                {
                    return(false);
                }
            });
        }
コード例 #8
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
        }
コード例 #9
0
        public NamedPipeCommunication(string str)//コンストラクタ
        {
            name         = str;
            waitDelegate = WaitConnectionOnDelegate;
            readDelegate = ReadOnDelegate;
            connectState = ConnectState.notBornYet;

            ConnectStateLabel = "パイプ作成";
            MessageLabel      = "";

            try
            {
                connectState = ConnectState.born;
                pipeS        = new NamedPipeServerStream(str, PipeDirection.In, 1, PipeTransmissionMode.Byte);
            }
            catch (Exception e)
            {
                ConnectStateLabel = "パイプ作成に失敗";
                MessageBox.Show(e.ToString());
                connectState = ConnectState.dead;
            }
        }
コード例 #10
0
ファイル: loadSceneForm.cs プロジェクト: XluNl/C_project
 private void wait(bool exit)
 {
     if (this.InvokeRequired)
     {
         WaitDelegate w = new WaitDelegate(wait);
         this.Invoke(w, exit);
     }
     else
     {
         if (exit)
         {
             //游戏结束,退出
             MessageBox.Show("演练流程结束", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             ClientDAL.GetInstance().stopThread();
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             //游戏未结束,等待
             this.panel1.Controls.Add(lblWait);
         }
     }
 }
コード例 #11
0
ファイル: Room.cs プロジェクト: jabbo/Jabbo
 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);
     }
 }
コード例 #12
0
 public WaitWindow(Window owner, string title, WaitDelegate waitAction) : this(owner, title, waitAction, null)
 {
 }
コード例 #13
0
ファイル: Client.cs プロジェクト: sanchaz/PADITable
 /// <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);
 }
コード例 #14
0
ファイル: DynamicEval.cs プロジェクト: ndrarmstrong/ece150
        /// <summary>
        /// Initializes a new instance of the DynamicEval class.
        /// </summary>
        /// <param name="highlightDelegate">An implementation of the 'Highlight' function.</param>
        /// <param name="highlightBoxDelegate">An implementation of the 'HighlightBox' function.</param>
        /// <param name="waitDelegate">An implementation of the 'Wait' function.</param>
        public DynamicEval(HighlightDelegate highlightDelegate, HighlightBoxDelegate highlightBoxDelegate, WaitDelegate waitDelegate)
        {
            this.highlightDelegate = highlightDelegate;
            this.highlightBoxDelegate = highlightBoxDelegate;
            this.waitDelegate = waitDelegate;

            this.Initialize();
        }