Esempio n. 1
0
 public void Stop()
 {
     lock (_lock)
     {
         IDEAGateway.Request(JsonConvert.SerializeObject(OperationReference, IDEAGateway.JsonSerializerSettings), "pause");
         _isRunning = false;
     }
 }
Esempio n. 2
0
        private async void run()
        {
            try
            {
                var response = await IDEAGateway.Request(JsonConvert.SerializeObject(OperationParameters, IDEAGateway.JsonSerializerSettings), "operation");

                OperationReference = JsonConvert.DeserializeObject <OperationReference>(response, IDEAGateway.JsonSerializerSettings);

                var resultCommand = new ResultCommand();

                // starting looping for updates
                while (_isRunning)
                {
                    var result = await resultCommand.GetResult(OperationReference);

                    if (result != null)
                    {
                        FireJobUpdated(new JobEventArgs {
                            Result = result, ResultExecutionId = _executionId
                        });

                        if (result.Progress >= 1.0)
                        {
                            _isRunning = false;
                            FireJobCompleted(new JobEventArgs {
                                Result = result, ResultExecutionId = _executionId
                            });
                        }
                    }
                    await Task.Delay(_throttle);
                }
            }
            catch (Exception exc)
            {
                ErrorHandler.HandleError(exc.Message);
            }
        }