1

I have two WCF service calls:

[OperationContract]
void ClosePeriod();
[OperationContract]
string GetLogs();

ClosePeriod method runs a stored procedure that takes 1 hour, and it generates log messages. GetLogs method returns the log messages generated from ClosePeriod method.

I'm trying to display the log messages on the ASP.Net webpage while waiting on the ClosePeriod service call.

<asp:UpdatePanel ID="UpdatePanelClosing" runat="server">
    <ContentTemplate>
        <asp:Timer ID ="TimerLog" runat ="server" Interval ="3000" OnTick="TimerLog_Tick" Enabled="true"></asp:Timer>
        <table>         
            <tr>
                <td>
                    <div style="margin-top: 10px; margin-bottom: 70px">
                        <asp:Button runat="server" ID="BtnExecuteClosing" Text="Execute" Width="105px" Height="35px"  OnClick="BtnExecuteClosing_Click" />
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <p>Process Log:</p>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:TextBox ID="TxtProcessLog" runat="server" Width="930px" Height="270" TextMode="MultiLine" Style="resize: none;"
                        ReadOnly="true" Text=""> 
                    </asp:TextBox>
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>

so far I tried to call ClosePeriod method asynchronously, and I tried to update TxtProcessLog textbox using the timer.

protected async void BtnExecuteClosing_Click(object sender, EventArgs e)        
{
    await webservice.ClosePeriodAsync();
}

protected void TimerLog_Tick(object sender, EventArgs e)
{
    string log = webservice.GetLogs();
    TxtProcessLog.Text = log ; 

}

But the TxtProcessLog textbox is updated after the ClosePeriod service call is completed. Am I doing something wrong? Please suggest any other approaches.

4

1 回答 1

1

ClosePeriod 是做什么的?将许多日志写入数据库表?那么你的代码应该可以正常工作。如果“webservice.GetLogs()”返回 string.empty,则不会显示任何内容。来自 UpdatePanel 的 ClosePeriod 调用应该是异步的,否则所有后续调用都将被阻止。

于 2013-08-08T14:23:27.637 回答