public ModelProgressStatus Load(LoadModelFromSASParams loadModelParams) { var machine = AppServices.RemoteRendering?.PrimaryMachine; if (machine == null) { var msg = $"Unable to load model: this is no remote rendering session. (url = {loadModelParams.ModelUrl})"; Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, msg); AppServices.AppNotificationService.RaiseNotification(msg, AppNotificationType.Error); return(null); } if (machine.Session.Connection.ConnectionStatus != ConnectionStatus.Connected) { var msg = $"Unable to load model: manager is not connected. (url = {loadModelParams.ModelUrl})"; Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, msg); AppServices.AppNotificationService.RaiseNotification(msg, AppNotificationType.Error); return(null); } ModelProgressStatus progressTask = new ModelProgressStatus(); ScaleLoad(loadModelParams, progressTask); return(progressTask); }
public Task <LoadModelResult> Load(RemoteModel model, Entity parent) { var machine = AppServices.RemoteRendering?.PrimaryMachine; if (machine == null) { var msg = $"Unable to load model: this is no remote rendering session. (url = {model.Url})"; Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, "{0}", msg); AppServices.AppNotificationService.RaiseNotification(msg, AppNotificationType.Error); return(null); } if (machine.Session.Connection.ConnectionStatus != ConnectionStatus.Connected) { var msg = $"Unable to load model: manager is not connected. (url = {model.Url})"; Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, null, "{0}", msg); AppServices.AppNotificationService.RaiseNotification(msg, AppNotificationType.Error); return(null); } ModelProgressStatus progressTask = new ModelProgressStatus(); var loadModelTask = ScaleLoad(model, parent, progressTask); return(loadModelTask); }
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)); } } }