I am trying to indicate on my aspx page that it is processing the request. Maybe this isn't the best way to go about doing it. But I can't seem to find a another way to get this to work. I Hope what I'm trying to do makes sense. I appreciate any help and suggestions.
Anyway here is the ASPX code:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="content">
<style type="text/css">
#UpdatePanel1, #UpdatePanel2, #UpdateProgress1 {
border-right: gray 1px solid; border-top: gray 1px solid;
border-left: gray 1px solid; border-bottom: gray 1px solid;
}
#UpdatePanel1, #UpdatePanel2 {
width:200px; height:200px; position: relative;
float: left; margin-left: 10px; margin-top: 10px;
}
#UpdateProgress1 {
width: 400px; background-color: #FFC080;
bottom: 0%; left: 0px; position: absolute;
}
</style>
<div>
<asp:ScriptManager ID="ScriptManager2" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<%=DateTime.Now.ToString(CultureInfo.InvariantCulture) %> <br />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Archiving...
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<ul>
<li>
<span>
<asp:ImageButton ID="ArchiveImageButton" runat="server" AlternateText="Archive Compliance"
ImageUrl="~/images/Icons/24/452-bank.gif" OnClick="Button_Click" ToolTip="Archive compliance results" />
</span>
</li>
</ul>
</td>
</tr>
And Here is the C# Code-Behind:
private bool archiving;
protected void Button_Click(object sender, EventArgs e)
{
archiving = true;
WaitHandle wait = new EventWaitHandle(false, EventResetMode.AutoReset);
ThreadPool.QueueUserWorkItem(state => btnArchive_Click(sender, e));
ThreadPool.QueueUserWorkItem(sleepState => Sleep());
ThreadPool.RegisterWaitForSingleObject(wait, delegate { WakeMeUp(); }, false, 9999999999999999, true);
}
private void WakeMeUp()
{
archiving = false;
}
private void Sleep()
{
while (archiving)
{
Thread.Sleep(1);
}
}
protected void btnArchive_Click(object sender, EventArgs e)
{
//DO WORK
ShowSuccessMessage("Compliance results have been archived.");
}