Example #1
0
 void DefaultData()
 {
     ProgressCollection.Add("To Do");
     ProgressCollection.Add("In Progress");
     ProgressCollection.Add("Ready");
     ProgressCollection.Add("In QA Review");
     ProgressCollection.Add("Done");
 }
        private async void ScaleLoad(LoadModelFromSASParams loadModelParams, ModelProgressStatus progressTask)
        {
            var machine = AppServices.RemoteRendering?.PrimaryMachine;

            // Remember the current connection, so we can cancel the load on a new connection
            uint connectionId = _connectionId;

            LoadModelAsync loadOperation = null;

            _progress.Add(progressTask);

            while (true)
            {
                if (machine == null)
                {
                    var msg = $"Unable to load model: there is no remote rendering session. (url = {loadModelParams.ModelUrl})";
                    Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, msg);
                    AppServices.AppNotificationService.RaiseNotification(msg, AppNotificationType.Error);
                    break;
                }

                lock (_loadingTasks)
                {
                    if (_loadingTasks.Count == 0 ||
                        _loadingTasks.Count < _remoteObjectFactoryServiceProfile.ConcurrentModelLoads)
                    {
                        loadOperation = machine.Actions.LoadModelAsyncAsOperation(loadModelParams);
                        break;
                    }
                }

                await Task.WhenAll(_loadingTasks);

                lock (_loadingTasks)
                {
                    _loadingTasks.Clear();
                }
            }

            if (loadOperation != null)
            {
                if (_connectionId != connectionId)
                {
                    progressTask.Start(null);
                }
                else
                {
                    progressTask.Start(loadOperation);
                    _loadingTasks.Add(IgnoreFailure(progressTask.Result));
                }
            }
        }