Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Sep 1, 2022
1 parent dc7cbee commit fd1023c
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions CustomActionTester/CATcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Rappen.XTB.Helpers.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -174,30 +175,36 @@ private void ExecuteCA()
WorkAsync(new WorkAsyncInfo
{
Message = $"Executing {catTool.Target}",
Work = (worker, args) =>
{
var sw = Stopwatch.StartNew();
var result = Service.Execute(request);
sw.Stop();
args.Result = new Tuple<OrganizationResponse, long>(result, sw.ElapsedMilliseconds);
},
PostWorkCallBack = (args) =>
{
if (args.Error != null)
{
ShowErrorDialog(args.Error);
}
else if (args.Result is Tuple<OrganizationResponse, long> response)
{
txtExecution.Text = $"{response.Item2} ms";
btnPTV.Enabled = true;
var outputparams = response.Item1.Results;
PopulateOutputParamValues(outputparams);
}
}
AsyncArgument = request,
Work = ExecuteCAWork,
PostWorkCallBack = ExecuteCAPost
});
}

private void ExecuteCAWork(BackgroundWorker worker, DoWorkEventArgs args)
{
var request = args.Argument as OrganizationRequest;
var sw = Stopwatch.StartNew();
var result = Service.Execute(request);
sw.Stop();
args.Result = new Tuple<OrganizationResponse, long>(result, sw.ElapsedMilliseconds);
}

private void ExecuteCAPost(RunWorkerCompletedEventArgs args)
{
if (args.Error != null)
{
ShowErrorDialog(args.Error);
}
else if (args.Result is Tuple<OrganizationResponse, long> response)
{
txtExecution.Text = $"{response.Item2} ms";
btnPTV.Enabled = true;
var outputparams = response.Item1.Results;
PopulateOutputParamValues(outputparams);
}
}

private OrganizationRequest GetRequest()
{
var request = new OrganizationRequest(GetApiMessage());
Expand Down

0 comments on commit fd1023c

Please sign in to comment.