We are have a Kentico CMSAbstractWebPart that interacts with a 3rd party service. The service historically used SOAP but has moved to JSON (an thus is async now).
All of our low-level commands are of type Task. To execute them outside of Kentico we invoke the calls with:
Task.Run(async () => { await task; });
However, when inside of Kentico, this will cause deadlocks with the UI. We are trying to use Kentico's AsyncWorker, but can't find the correct methods / parameters.
Here is an example of what we are trying:
AsyncWorker worker = new AsyncWorker();
worker.RunAsync(task, System.Security.Principal.WindowsIdentity.GetCurrent());
worker.WaitForFinish();
Any guidance you could give would be GREATLY appreciated!
Thank you!