I'm using c# (.aspx).

I have button OnClick callback as follow:

protected void btnReplay_Click(object sender, EventArgs e)
{
    Task.Factory.StartNew(() =>
    {
        //Code thats take 30secs to run
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "script", "ShowMessage('Done');", true);
    });
}

At this case ShowMessage function isn't called, but if i'm change the code as follow:

protected void btnReplay_Click(object sender, EventArgs e)
{
    //Code thats take 30secs to run
    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "script", "ShowMessage('Done');", true);
    });
}

The function ShowMessage is called.
Why its happend and How can i fix it? or you can suggest please any another way to execute my code?

Thanks

Related posts

Recent Viewed