Kentico-AsyncWorker(运行任务)

我们有一个与第三方服务交互的Kentico CMSAbstractWebPart。该服务过去使用SOAP,但已迁移到JSON(因此现在是异步的)。

我们所有的低级命令都是Task类型的。要在Kentico之外执行它们,我们使用以下命令调用调用:

Task.Run(async () => { await task; });

但是,在Kentico内部时,这将导致UI死锁。我们正在尝试使用Kentico的AsyncWorker,但找不到正确的方法/参数。

以下是我们正在尝试的示例:

AsyncWorker worker = new AsyncWorker();
worker.RunAsync(task,system.security.Principal.WindowsIdentity.getcurrent());
worker.WaitForFinish();

您能给予的任何指导将不胜感激!

谢谢!

morenming 回答:Kentico-AsyncWorker(运行任务)

可能有两件事需要检查:

1)检查\ Web \ CMS \ CMSPages \ PortalTemplate.aspx文件,使其在页面上包含Async =“ true”属性。

<%@ Page Language="C#" AutoEventWireup="true" Inherits="CMSPages_PortalTemplate" Async="true"
ValidateRequest="false" MaintainScrollPositionOnPostback="true" EnableEventValidation="false"
Codebehind="PortalTemplate.aspx.cs" %>

2)无论如何,您的Web部件代码无论如何都将被同步调用,您是否尝试按照this article中的描述显式地同步调用它?

本文链接:https://www.f2er.com/2707950.html

大家都在问