开发者

Does calling a delegate defined with a signature (e.g.) Func<t,t> type excecute synchronously in ASP.NET?

开发者 https://www.devze.com 2023-04-06 20:35 出处:网络
On first examination it appears that it does. A quick examination of the call stack shows that the method passed to the delegate is executed as one would expect. However....

On first examination it appears that it does. A quick examination of the call stack shows that the method passed to the delegate is executed as one would expect. However....

In calling the delegate in a "click event" and trying to modify controls (e.g. visibility, binding, updating update panels) nothing happens (In fact for an explicit call to an UpdatePanel.Update an exception is thrown saying that the method can not be called after Render - for all intents and purposes though, Im perceivably NOT at that stage in the page lifecycle, but rather in a control event - invariably handled as a postback event, always before Render, to my best knowledge.).

However... When returning to the call site and executing the same code (just after the delegate call) that I tried to execute (from within the method called by the delegate) to affect changes on various controls, it works.

What could be going on?

EDIT Framework code:

IModalWorkflowItem
{
    void ExecuteWorkflow();
    .....
}

public abstract class BaseModalWorkflow : IModalWorkflowItem
{
    ....
    protected Func<String, IMinervaValidator , Boolean>_action;
    ....

    /// <summary>
    /// Using the properties (if necessary) perform the action
    /// required on completion of modal workflow
    /// </summary>
    /// <returns></returns>;
    protected abstract Boolean PerformAction(PropertyBag properties);
    }

Creation of object passing in lambda as anonymous method...

    new ModalWorkflowUserGroupAction(ModalPopupExtender_UserPrompt,
                   Session,
                   (x, y) =>
                     {
                         if (UserGroupManager.UserAccessToUserGroup(membershipID,
                             CurrentUserGroup.UserGroupID, false))
                         {
                             BindUserList();

Actual call:

/// <summary>
/// Call the next action in the modal workflow. 
/// </summary>
开发者_StackOverflow社区/// <param name="sender"></param>
/// <param name="e"></param>
protected void ExpandingButton_ModalConfirmContinue_Click
                                 (Object sender, EventArgs e)
{
    if (CurrentModalWorkFlowItem != null)
    {
        CurrentModalWorkFlowItem.ExecuteWorkflow();


Yes, calling any delegate occurs synchronously, in any .NET program type. This sort of thing doesn't suddenly change just because you happen to be using ASP.NET.

0

精彩评论

暂无评论...
验证码 换一张
取 消