Example #1
0
        public override void CopyNode(Node original)
        {
            base.CopyNode(original);
            var node = (WaitNode)original;

            GetSceneBy            = node.GetSceneBy;
            WaitFor               = node.WaitFor;
            AnyValue              = node.AnyValue;
            IgnoreUnityTimescale  = node.IgnoreUnityTimescale;
            RandomDuration        = node.RandomDuration;
            Duration              = node.Duration;
            DurationMax           = node.DurationMax;
            DurationMin           = node.DurationMin;
            SceneBuildIndex       = node.SceneBuildIndex;
            GameEvent             = node.GameEvent;
            SceneName             = node.SceneName;
            UIViewTriggerAction   = node.UIViewTriggerAction;
            ViewCategory          = node.ViewCategory;
            ViewName              = node.ViewName;
            UIButtonTriggerAction = node.UIButtonTriggerAction;
            ButtonCategory        = node.ButtonCategory;
            ButtonName            = node.ButtonName;
            UIDrawerTriggerAction = node.UIDrawerTriggerAction;
            DrawerName            = node.DrawerName;
            CustomDrawerName      = node.CustomDrawerName;
        }
Example #2
0
 internal StWaitBlock (StParker pk, WaitType t, int r, int k)
 {
     parker = pk;
     waitType = t;
     request = r;
     waitKey = k;
 }
Example #3
0
        static public IEnumerator Wait(this IEnumerator wait, float num, WaitType type = WaitType.Seconds, int loop = 1)
        {
            switch (type)
            {
            case WaitType.Seconds:
                yield return(new WaitForSeconds(num));

                break;

            case WaitType.SecondsRealtime:
                yield return(new WaitForSecondsRealtime(num));

                break;

            case WaitType.Frames:
                int frameCount = Mathf.CeilToInt(num);
                for (int i = 0; i < frameCount; i++)
                {
                    yield return(new WaitForEndOfFrame());
                }
                break;

            case WaitType.FixUpdate:
                int fixUpdateCount = Mathf.CeilToInt(num);
                for (int i = 0; i < fixUpdateCount; i++)
                {
                    yield return(new WaitForFixedUpdate());
                }
                break;
            }
            yield return(wait);
        }
Example #4
0
        public T Wait <T>(double seconds, WaitType waitType, Func <string> errorMessageFunc, Func <IWebDriver, T> func)
        {
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));

            try
            {
                return(wait.Until(func));
            }
            catch (WebDriverTimeoutException ex)
            {
                var message = errorMessageFunc();
                switch (waitType)
                {
                case WaitType.Validation: throw new BrowserMonkeyValidationException(message, ex);

                case WaitType.Interaction: throw new BrowserMonkeyInteractionException(message, ex);

                case WaitType.Element: throw new BrowserMonkeyElementException(message, ex);

                case WaitType.Page: throw new BrowserMonkeyPageException(message, ex);

                default: throw;
                }
            }
            catch (BrowserMonkeyValidationException) { throw; }
            catch (BrowserMonkeyInteractionException) { throw; }
            catch (BrowserMonkeyElementException) { throw; }
            catch (BrowserMonkeyPageException) { throw; }
            catch { return(default(T)); }
        }
Example #5
0
 public static extern NtStatus NtWaitForMultipleObjects(
     [In] uint Count,
     [In] IntPtr[] Handles,
     [In] WaitType WaitType,
     [In, MarshalAs(UnmanagedType.I1)] bool Alertable,
     [In, Out, Optional] ref long Timeout
     );
Example #6
0
        private static NtStatus WaitForMultipleObjects(ISynchronizable[] objects, WaitType waitType, bool alertable, long timeout, bool relative)
        {
            NtStatus status;

            IntPtr[] handles     = new IntPtr[objects.Length];
            long     realTimeout = relative ? -timeout : timeout;

            for (int i = 0; i < objects.Length; i++)
            {
                handles[i] = objects[i].Handle;
            }

            if ((status = Win32.NtWaitForMultipleObjects(
                     handles.Length,
                     handles,
                     waitType,
                     alertable,
                     ref realTimeout
                     )) >= NtStatus.Error)
            {
                Win32.ThrowLastError(status);
            }

            return(status);
        }
Example #7
0
 internal StWaitBlock (WaitType t, int r, int k)
 {
     parker = new StParker ();
     waitType = t;
     request = r;
     waitKey = k;
 }
Example #8
0
        /// <summary>
        /// Wait until an element is no longer attached to the DOM.
        /// </summary>
        /// <param name="locator">Locator for the web element.</param>
        /// <param name="waitType">Type of wait from <see cref="WaitType"/>.</param>
        public void WaitForElementStaleness(By locator, WaitType waitType)
        {
            bool result = false;

            try
            {
                TimeSpan      time = GetWait(waitType);
                IWebElement   elem = (new SeleniumActions()).FindElement(locator);
                WebDriverWait wait = new WebDriverWait(Driver, time);
                result = wait.Until(ExpectedConditions.StalenessOf(elem));
                if (!result)
                {
                    throw new WebDriverTimeoutException();
                }
            }
            catch (WebDriverTimeoutException e)
            {
                string message = string.Format(" The element '{0}' is still attached with DOM in given wait time: '{1}'", locator, waitType.ToString());
                CustomExceptionHandler.CustomException(e, message);
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e);
            }
        }
Example #9
0
 internal WaitBlock(WaitType t, int r, int k)
 {
     parker   = new StParker();
     waitType = t;
     request  = r;
     waitKey  = k;
 }
Example #10
0
        /// <summary>
        /// Waits for a slot event, such as token insertion or token removal, to occur
        /// </summary>
        /// <param name="waitType">Type of waiting for a slot event</param>
        /// <param name="eventOccured">Flag indicating whether event occured</param>
        /// <param name="slotId">PKCS#11 handle of slot that the event occurred in</param>
        public void WaitForSlotEvent(WaitType waitType, out bool eventOccured, out ulong slotId)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            if (Platform.UnmanagedLongSize == 4)
            {
                uint uintSlotId = CK.CK_INVALID_HANDLE;

                if (Platform.StructPackingSize == 0)
                {
                    _p11_40.WaitForSlotEvent(waitType, out eventOccured, out uintSlotId);
                }
                else
                {
                    _p11_41.WaitForSlotEvent(waitType, out eventOccured, out uintSlotId);
                }

                slotId = uintSlotId;
            }
            else
            {
                if (Platform.StructPackingSize == 0)
                {
                    _p11_80.WaitForSlotEvent(waitType, out eventOccured, out slotId);
                }
                else
                {
                    _p11_81.WaitForSlotEvent(waitType, out eventOccured, out slotId);
                }
            }
        }
Example #11
0
 internal WaitBlock(StParker pk, WaitType t, int r, int k)
 {
     parker   = pk;
     waitType = t;
     request  = r;
     waitKey  = k;
 }
Example #12
0
 protected void SetWait0(WaitType WaitType, String WaitDescription, bool HandleCallbacks)
 {
     this.CurrentStatus   = Status.Waiting;
     this.CurrentWaitType = WaitType;
     this.WaitDescription = WaitDescription;
     this.HandleCallbacks = HandleCallbacks;
 }
Example #13
0
        /// <summary>
        /// This method returns wait time based on the specified wait type.
        /// </summary>
        /// <param name="waitType">Type of wait from <see cref="WaitType"/>.</param>
        /// <returns><see cref="TimeSpan"/> wait time based on <see cref="WaitType"/> specified.</returns>
        public TimeSpan GetWait(WaitType waitType)
        {
            TimeSpan waitTime = TimeSpan.FromSeconds(0);

            try
            {
                switch (waitType)
                {
                case WaitType.Small:
                    waitTime = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["SmallWait"]));
                    break;

                case WaitType.Medium:
                    waitTime = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["MediumWait"]));
                    break;

                case WaitType.Large:
                    waitTime = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["LargeWait"]));
                    break;

                case WaitType.ImplicitWaitTime:
                    waitTime = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["ImplicitWaitTime"]));
                    break;

                default:
                    throw new Exception("Undefined Wait Type.");
                }
            }
            catch (Exception e)
            {
                CustomExceptionHandler.CustomException(e);
            }
            return(waitTime);
        }
Example #14
0
        /// <summary>
        /// Waits for data to be received.  During execution this method will enter a spin-wait loop and appear to use
        /// 100% cpu when in fact it is just a suspended thread.   This is much more efficient than waiting a
        /// millisecond since most commands take fractions of a millisecond. It will either resume after the condition
        /// is met or throw a timeout exception.
        /// </summary>
        /// <param name="type">Wait type</param>
        public void Wait(WaitType type)
        {
            if (XboxClient.XboxName != null)
            {
                Stopwatch sw = Stopwatch.StartNew();
                switch (type)
                {
                // waits for data to start being received
                case WaitType.Partial:
                    while (XboxClient.XboxName.Available == 0)
                    {
                        Thread.Sleep(0);
                        if (sw.ElapsedMilliseconds > 5000)
                        {
                        }
                    }
                    break;

                // waits for data to start and then stop being received
                case WaitType.Full:

                    // do a partial wait first
                    while (XboxClient.XboxName.Available == 0)
                    {
                        Thread.Sleep(0);
                        if (sw.ElapsedMilliseconds > 5000)
                        {
                        }
                    }

                    // wait for rest of data to be received
                    int avail = XboxClient.XboxName.Available;
                    Thread.Sleep(0);
                    while (XboxClient.XboxName.Available != avail)
                    {
                        avail = XboxClient.XboxName.Available;
                        Thread.Sleep(0);
                    }
                    break;

                // waits for data to stop being received
                case WaitType.Idle:
                    int before = XboxClient.XboxName.Available;
                    Thread.Sleep(0);
                    while (XboxClient.XboxName.Available != before)
                    {
                        before = XboxClient.XboxName.Available;
                        Thread.Sleep(0);
                        if (sw.ElapsedMilliseconds > 5000)
                        {
                        }
                    }
                    break;
                }
            }
            else
            {
                throw new Exception("No Connection Detected");
            }
        }
Example #15
0
        internal WaitBlock WaitWithParker(StParker pk, WaitType type, int key, ref int sc)
        {
            WaitBlock wb = null;

            do
            {
                WaitBlock s;
                if ((s = state) == SET)
                {
                    return(null);
                }

                if (wb == null)
                {
                    wb = new WaitBlock(pk, type, 0, key);
                }

                wb.next = s;
                if (Interlocked.CompareExchange(ref state, wb, s) == s)
                {
                    sc = s == null ? spinCount : 0;
                    return(wb);
                }
            } while (true);
        }
Example #16
0
 public static NakiType GetNakiType(WaitType wait)
 {
     if (!(initialized))
     {
         Initialize();
     }
     return(waitNaki[wait]);
 }
Example #17
0
 /// <summary>
 /// フレーム指定遅延実行データ
 /// </summary>
 public DelayedCallData(int delay, Action action, MonoBehaviour invoker)
 {
     id = _delayedId++;
     this.frameDelay = delay;
     this.action     = action;
     this.invoker    = invoker;
     this.type       = WaitType.FRAME;
 }
Example #18
0
 /// <summary>
 /// 秒数指定遅延実行データ
 /// </summary>
 public DelayedCallData(float delay, Action action, MonoBehaviour invoker)
 {
     id           = _delayedId++;
     this.delay   = delay;
     this.action  = action;
     this.invoker = invoker;
     this.type    = WaitType.SECOND;
 }
Example #19
0
 public static string WaitTypeString(WaitType type)
 {
     if (!(initialized))
     {
         Initialize();
     }
     //return waitTypeStrings[type];
     return("Waiting"); //TODO: this is for test showcasing only
 }
Example #20
0
    public void Show(WaitType waitType, float _delay = 0f)
    {
        if (!this.waitings.Contains(waitType))
        {
            this.waitings.Add(waitType);
        }

        OpenWindow();
    }
Example #21
0
 internal ForUpdateClause(ForUpdateOfClause ofClause
                          , WaitType waitType
                          , int waitTime
                          , Comments comments)
 {
     this.Comments = comments;
     this.OfClause = ofClause;
     this.WaitType = waitType;
     this.WaitTime = waitTime;
 }
Example #22
0
        public static bool Wait(Locator locator, WaitType waitType, ISearchContext container = null, int timeout = TimeManager.WAITELEMENTTIMEOUT)
        {
            Func <IWebDriver, bool> AppearCondition = (driver) => Displayed(locator, container: (container == null ? driver : container));

            Func <IWebDriver, bool> DisappearCondition = (driver) => !Displayed(locator, container: (container == null ? driver : container));

            WebDriverWait wait = new WebDriverWait(DriverFactory.Instance, TimeSpan.FromSeconds(timeout));

            return(wait.Until <bool>(waitType == WaitType.ToAppear ? AppearCondition : DisappearCondition));
        }
Example #23
0
 public void ShowDialogue(DialogueId eventId, WaitType waitType)
 {
     if (!_playerControl.ThePlayer.IsAlive() || Toolbox.Instance.TooltipCompleted(eventId))
     {
         return;
     }
     _waitType = waitType;
     Toolbox.Instance.SetTooltipComplete(eventId);
     TooltipId[] dialogue = _dialogueSet[eventId];
     StartCoroutine("SetupDialogue", dialogue);
 }
Example #24
0
    public void Hide(WaitType waitType)
    {
        if (this.waitings.Contains(waitType))
        {
            this.waitings.Remove(waitType);
        }

        if (this.waitings.Count == 0)
        {
            CloseWindow();
        }
    }
Example #25
0
        public static bool NewJazz_Wait(Locator locator, WaitType waitType, ISearchContext container = null, int timeout = TimeManager.WAITELEMENTTIMEOUT)
        {
            Console.Out.WriteLine(waitType.ToString());

            Func <IWebDriver, bool> AppearCondition = (driver) => Exists(locator, container: (container == null ? driver : container));

            Func <IWebDriver, bool> DisappearCondition = (driver) => !Exists(locator, container: (container == null ? driver : container));

            WebDriverWait wait = new WebDriverWait(DriverFactory.Instance, TimeSpan.FromSeconds(timeout));

            return(wait.Until <bool>(waitType == WaitType.ToAppear ? AppearCondition : DisappearCondition));
        }
        public static void GoToMissingGamesPage([NotNull] IWebDriver driver, WaitType waitType = WaitType.PageLoad)
        {
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            Console.WriteLine(Invariant($"Navigating to missing games page URL: {SiteConstants.MissingGamesPage}..."));
            driver.Url = SiteConstants.MissingGamesPage;

            WaitForLoad(driver, waitType);
        }
Example #27
0
 /// <summary>
 /// An expectation for wait and check whether the given frame is available to switch to. If the frame is available it switches the driver to the specified frame.
 /// </summary>
 /// <param name="locator">Locator for the web element.</param>
 /// <param name = "waitType" > Type of wait from <see cref="WaitType"/>.</param>
 public void WaitAndSwitchToFrame(By locator, WaitType waitType)
 {
     try
     {
         TimeSpan      time = GetWait(waitType);
         WebDriverWait wait = new WebDriverWait(Driver, time);
         wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(locator));
     }
     catch (Exception e)
     {
         CustomExceptionHandler.CustomException(e, "Timeout exception while waiting for frame: " + locator);
     }
 }
Example #28
0
 /// <summary>
 ///  Waits for alert to be present.
 /// </summary>
 /// <param name="waitType">Type of wait from <see cref="WaitType"/>.</param>
 public void WaitForAlertToBePresent(WaitType waitType)
 {
     try
     {
         TimeSpan      time = GetWait(waitType);
         WebDriverWait wait = new WebDriverWait(Driver, time);
         wait.Until(ExpectedConditions.AlertIsPresent());
     }
     catch (Exception e)
     {
         CustomExceptionHandler.CustomException(e);
     }
 }
Example #29
0
 /// <summary>
 /// An expectation for checking that an element is present on the DOM of a page and visible.
 /// </summary>
 /// <param name="locator">Locator for the web element.</param>
 /// <param name="waitType">Type of wait from <see cref="WaitType"/>.</param>
 public void WaitForElementToBeVisible(By locator, WaitType waitType)
 {
     try
     {
         TimeSpan      time = GetWait(waitType);
         WebDriverWait wait = new WebDriverWait(Driver, time);
         wait.Until(ExpectedConditions.ElementIsVisible(locator));
     }
     catch (Exception e)
     {
         string message = string.Format(" Locator : '{0}'", locator);
         CustomExceptionHandler.CustomException(e, message);
     }
 }
Example #30
0
        public static void GetInstanceStats()
        {
            DataSet sqlinstances = GetSQLInstances.SQLInstances();

            foreach (DataTable table in sqlinstances.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    long ple = PageLifeExpectancy.GetPageLifeExpectancy(row["name"].ToString());
                    WaitType.GetWaitStats(row["name"].ToString(), (int)row["Id"]);
                    SQLMonitorUpdateDB.UpdateInstancestats((int)row["id"], ple);
                }
            }
        }
        /// <summary>
        /// Called by parent class for drawing specific variables at top.
        /// Parent class should automatically check for when it is dirty.
        /// </summary>
        protected override void DrawChildInspector()
        {
            waitType = (WaitType)EditorGUILayout.EnumPopup("Wait Type", waitType);

            switch (waitType)
            {
            case WaitType.Seconds:
                Draw_WaitType_Seconds();
                break;

            case WaitType.Frames:
                Draw_WaitType_Frames();
                break;
            }
        }
Example #32
0
            public void Runs_Task_To_Clean_And_Returns_Task(WaitType waitType)
            {
                TestObject.WaitType = waitType;

                var actual = TestObject.Cleanup();

                Assert.That(actual, Is.EqualTo(_task));
                Mock <ITaskRunner>().Verify(x => x.Run(It.IsAny <Action>(), waitType), Times.Once);
                Mock <ITaskRunner>().Verify(x => x.Run(It.IsAny <Action>(), It.IsAny <WaitType>()), Times.Once);
                Mock <IDirectoryCleaner>().Verify(x => x.Clean(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime?>(), It.IsAny <long?>()), Times.Never);

                _action();

                Mock <IDirectoryCleaner>().Verify(x => x.Clean(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime?>(), It.IsAny <long?>()), Times.Once);
            }
Example #33
0
        public void SetWaitAndPrepareWakeUp(WaitType WaitType, String WaitDescription, object WaitObject, Action<WakeUpCallbackDelegate> PrepareCallback, bool HandleCallbacks = false)
        {
            if (this.CurrentStatus == Status.Waiting)
            {
                Console.Error.WriteLine("Trying to sleep an already sleeping thread!");
            }

            bool CalledAlready = false;
            YieldCount++;
            SetWait0(WaitType, WaitDescription, WaitObject, HandleCallbacks);
            {
                //PrepareCallback(WakeUp);
                PrepareCallback(() =>
                {
                    if (!CalledAlready)
                    {
                        CalledAlready = true;
                        WakeUp();
                    }
                });
            }
            SetWait1();
        }
Example #34
0
		private StWaitBlock WaitWithParker (StParker pk, WaitType type, int key, 
														ref StWaitBlock hint, ref int sc)
      {
         StWaitBlock wb = null;
         do {
            StWaitBlock s;
            if ((s = state) == SET) {
               return null;
            }

				if (s == INFLATED) {
					hint = INFLATED;
					return null;
				}

            if (wb == null) {
               wb = new StWaitBlock (pk, type, 0, key);
            }

            wb.next = s;
            if (Interlocked.CompareExchange (ref state, wb, s) == s) {
               sc = s == null ? spinCount : 0;
               return wb;
            }
         } while (true);
      }
        //
        // Constructor used with sentinel wait blocks.
        //

        internal WaitBlock() {
            waitType = WaitType.WaitAny;
            request = 0x13081953;
            waitKey = StParkStatus.Success;
        }
 internal WaitBlock(WaitType t) {
     parker = new StParker();
     waitType = t;
 }
 internal WaitBlock(WaitType t, int r) {
     parker = new StParker();
     waitType = t;
     request = r;
 }
Example #38
0
		private StWaitBlock WaitPrologue (StParker pk, WaitType type, int key, 
													 ref StWaitBlock hint, ref int sc) 
		{
			if (state == SEM_INFLATED) {
				hint = INFLATED;
				return null;
			}

			var wb = new StWaitBlock (pk, type, 1, key);
			sc = EnqueueAcquire (wb, 1);
			
			if (state == SEM_INFLATED && pk.TryCancel ()) {
				pk.UnparkSelf (StParkStatus.Inflated);
				hint = INFLATED;
				return null;
			}

			return wb;
		}
Example #39
0
        /// <summary>
        /// Waits for data to be received.  During execution this method will enter a spin-wait loop and appear to use 100% cpu when in fact it is just a suspended thread.  
        /// This is much more efficient than waiting a millisecond since most commands take fractions of a millisecond.
        /// It will either resume after the condition is met or throw a timeout exception.
        /// </summary>
        /// <param name="type">Wait type</param>
        public void Wait(WaitType type)
        {
            if (connection == null) throw new NoConnectionException("Must connect first.");

            DateTime before = DateTime.Now;
            TimeSpan elapse = new TimeSpan();

            switch (type)
            {
                case WaitType.Partial:
                    while (connection.Available == 0)
                    {
                        Thread.Sleep(0);
                        elapse = DateTime.Now - before;
                        if (elapse.TotalMilliseconds > timeout)
                        {
                            Disconnect();
                            throw new TimeoutException("Operation timed out.");
                        }
                    }
                    break;

                case WaitType.Full:

                    // do a partial wait first
                    while (connection.Available == 0)
                    {
                        Thread.Sleep(0);
                        elapse = DateTime.Now - before;
                        if (elapse.TotalMilliseconds > timeout)
                        {
                            Disconnect();
                            throw new TimeoutException("Operation timed out.");
                        }
                    }

                    // wait for rest of data to be received
                    int avail = connection.Available;
                    while (connection.Available != avail)
                    {
                        avail = connection.Available;
                        Thread.Sleep(0);
                    }
                    break;
            }
        }
 public static extern NtStatus NtWaitForMultipleObjects(int HandleCount, 
     IntPtr[] Handles, WaitType WaitType, bool Alertable, LargeInteger Timeout);
Example #41
0
 public void SetWaitAndPrepareWakeUp(WaitType WaitType, String WaitDescription, Action<WakeUpCallbackDelegate> PrepareCallback, bool HandleCallbacks = false)
 {
     bool CalledAlready = false;
     YieldCount++;
     SetWait0(WaitType, WaitDescription, HandleCallbacks);
     {
         //PrepareCallback(WakeUp);
         PrepareCallback(() =>
         {
             if (!CalledAlready)
             {
                 CalledAlready = true;
                 WakeUp();
             }
         });
     }
     SetWait1();
 }
Example #42
0
 protected void SetWait0(WaitType WaitType, String WaitDescription, object WaitObject, bool HandleCallbacks)
 {
     this.CurrentStatus = Status.Waiting;
     this.CurrentWaitType = WaitType;
     this.WaitDescription = WaitDescription;
     this.WaitObject = WaitObject;
     this.HandleCallbacks = HandleCallbacks;
 }
Example #43
0
		/// <summary>
		/// Waits for data to be received.  During execution this method will enter a spin-wait loop and appear to use 100% cpu when in fact it is just a suspended thread.  
        /// This is much more efficient than waiting a millisecond since most commands take fractions of a millisecond.
        /// It will either resume after the condition is met or throw a timeout exception.
		/// </summary>
		/// <param name="type">Wait type</param>
		public void Wait(WaitType type)
		{
            if (connection != null)
            {
                Stopwatch sw = Stopwatch.StartNew();
                switch (type)
                {
                    // waits for data to start being received
                    case WaitType.Partial:
                        while (connection.Available == 0)
                        {
                            Thread.Sleep(SleepTime);
                            if (sw.ElapsedMilliseconds > timeout)
                            {
                                if (!Ping(250)) Disconnect();  // only disconnect if actually disconnected
                                throw new TimeoutException();
                            }
                        }
                        break;

                    // waits for data to start and then stop being received
                    case WaitType.Full:

                        // do a partial wait first
                        while (connection.Available == 0)
                        {
                            Thread.Sleep(SleepTime);
                            if (sw.ElapsedMilliseconds > timeout)
                            {
                                if (!Ping(250)) Disconnect();  // only disconnect if actually disconnected
                                throw new TimeoutException();
                            }
                        }

                        // wait for rest of data to be received
                        int avail = connection.Available;
                        Thread.Sleep(SleepTime);
                        while (connection.Available != avail)
                        {
                            avail = connection.Available;
                            Thread.Sleep(SleepTime);
                        }
                        break;

                    // waits for data to stop being received
                    case WaitType.Idle:
                        int before = connection.Available;
                        Thread.Sleep(SleepTime);
                        while (connection.Available != before)
                        {
                            before = connection.Available;
                            Thread.Sleep(SleepTime);
                            if (sw.ElapsedMilliseconds > timeout)
                            {
                                if (!Ping(250)) Disconnect();  // only disconnect if actually disconnected
                                throw new TimeoutException();
                            }
                        }
                        break;
                }
            }
            else throw new NoConnectionException();
		}