static bool WaitForUpdate(ref bool isDone, int timeout, bool errorOnTimeout = true)
        {
            s_Stopwatch.Reset();
            s_Stopwatch.Start();

            do
            {
                AssetStoreClient.Update();
                Thread.Sleep(10);
                if (AssetStoreClient.LoginError())
                {
                    Debug.LogError("Found Login error: " + AssetStoreClient.LoginErrorMessage);
                    break;
                }

                if (!isDone && s_Stopwatch.Elapsed.TotalSeconds > timeout)
                {
                    if (errorOnTimeout)
                    {
                        throw new TimeoutException("Asset Store batch mode operation timed out.");
                    }

                    break;
                }
            } while (!isDone);

            return(isDone);
        }
        static bool WaitForUpdate(ref bool isDone, int timeout)
        {
            s_Stopwatch.Reset();
            s_Stopwatch.Start();

            do
            {
                AssetStoreClient.Update();
                Thread.Sleep(10);
                if (!isDone && s_Stopwatch.Elapsed.TotalSeconds > timeout)
                {
                    throw new TimeoutException("Asset Store batch mode operation timed out.");
                }
            } while (!isDone);

            return(isDone);
        }
        private static void Update()
        {
            AssetStoreClient.Update();
            switch (CurrentState)
            {
            case State.Login:
                StartLogin();
                return;

            case State.WaitingForLogin:
                WaitingForLogin();
                return;

            case State.GetMetadata:
                StartGetMetadata();
                return;

            case State.WaitingForMetadata:
                WaitForMetadata();
                return;

            case State.Upload:
                UploadPackage();
                break;

            case State.WaitingForUpload:
                WaitForUpload();
                break;

            case State.Error:
            case State.Finished:
                Debug.Log("FINISHED");
                Finish();
                EditorApplication.update -= Update;
                OnFinished();
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }