DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 31 Jul 2007 07:08:02 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Amrit Kohli Amrit
          2    Aidy
                 3    Amrit Kohli
          4    John Saunders [MVP] john.saunders at trizetto.com
          5    Amrit Kohli


Everything stops when a Thread is running on the server   
Hello,

I have a button that starts up a Thread and runs it in the background.

While the Thread is running, all the Ajax controls, including the events 
fired by the PageRequestManager, stop firing until the Thread exits.  So, I 
have no way of updating the page while this Thread is running, which was the 
point of putting it on the Thread.

The Ajax timer stops firing.  Nothing works.  It's very frustrating.

Can someone please help me?

Thanks,

Amrit Kohli
Date:Tue, 31 Jul 2007 07:08:02 -0700   Author:  

Re: Everything stops when a Thread is running on the server   
Post some relevant code

"Amrit Kohli" <Amrit Kohli@discussions.microsoft.com> wrote in message 
news:A7A36A8A-002A-4D9B-AA95-F5F20CCE8B40@microsoft.com...

> Hello,
>
> I have a button that starts up a Thread and runs it in the background.
>
> While the Thread is running, all the Ajax controls, including the events
> fired by the PageRequestManager, stop firing until the Thread exits.  So, 
> I
> have no way of updating the page while this Thread is running, which was 
> the
> point of putting it on the Thread.
>
> The Ajax timer stops firing.  Nothing works.  It's very frustrating.
>
> Can someone please help me?
>
> Thanks,
>
> Amrit Kohli 
Date:Tue, 31 Jul 2007 15:46:32 +0100   Author:  

Re: Everything stops when a Thread is running on the server   
"Amrit Kohli" <Amrit Kohli@discussions.microsoft.com> wrote in message 
news:A7A36A8A-002A-4D9B-AA95-F5F20CCE8B40@microsoft.com...

> Hello,
>
> I have a button that starts up a Thread and runs it in the background.
>
> While the Thread is running, all the Ajax controls, including the events
> fired by the PageRequestManager, stop firing until the Thread exits.  So, 
> I
> have no way of updating the page while this Thread is running, which was 
> the
> point of putting it on the Thread.
>
> The Ajax timer stops firing.  Nothing works.  It's very frustrating.
>
> Can someone please help me?


Are you using Session state? I've recently read that requests for the same 
session are serialized.

BTW, I hope your background thread doesn't reference anything in the Page or 
Request, or any other part of the HttpContext. Once the page unloads, all of 
that data is invalid, even if your thread is still accessing it.
-- 
John Saunders [MVP]
Date:Tue, 31 Jul 2007 12:07:36 -0400   Author:  

Re: Everything stops when a Thread is running on the server   
Aidy,

Thanks for the response.

Here's the ASPX code:

	<ajax:ScriptManager id="ScriptManager1" runat="server"  
EnablePartialRendering="true" EnablePageMethods="true"/>
	<ajax:Timer ID="ajaxTimer" runat="server" Interval="1" 
OnTick="ajaxTimer_OnTick" />
    <ajax:UpdatePanel ID="upLoadTools" runat="server" 
UpdateMode="Conditional">
        <ContentTemplate>
			<div class="progress">
				<app:ProgressBar id="ImportProgressBar" height="20em" runat="server" />
			</div>
			<asp:Button ID="_btnLoadTools" runat="server" CssClass="formbutton" 
Text="Load Tools" OnClick="_btnLoadTools_Click" ToolTip="Load Tools" />
		</ContentTemplate>
		<Triggers>
			<ajax:AsyncPostBackTrigger ControlID="ajaxTimer" EventName="Tick" />
		</Triggers>
	</ajax:UpdatePanel>

And here's the code that starts the thread:

		protected void _btnLoadTools_Click(object sender, EventArgs e) {
			this.ajaxTimer.Enabled = true;
			Thread t = new Thread((ThreadStart)delegate { CreateTools(); });
			t.IsBackground = true;
			t.Start();
		}

And here's the code in the Tick event of the Timer:

		protected void ajaxTimer_OnTick(object sender, EventArgs e) {
			this.ImportProgressBar.Percentage = Percentage;
			this.upLoadTools.Update();
		}

The OnTick event dies after the Thread is started.  However, I did figure 
this out.

I put a conditional Sleep on the Thread that gives up the processor to the 
ASPX worker process.  The problem is that the Thread was basically hogging 
the ASPX worker process and wouldn't give up any time to the client.  With 
some strategically placed Thread.Sleeps, I was able to get the progress bar 
to update correctly.

What I didn't realize is that this isn't the same kind of multi-threading 
enviornment that I'm familiar with.  If you start a Thread in the ASPX worker 
process' space, it basically takes over the whole process space.  If you 
don't put it to sleep, it'll rarely give up the time to the client.

Thanks for the help and I hope this helps others figure out this problem.

Amrit
"Aidy" wrote:


> Post some relevant code
> 
> "Amrit Kohli" <Amrit Kohli@discussions.microsoft.com> wrote in message 
> news:A7A36A8A-002A-4D9B-AA95-F5F20CCE8B40@microsoft.com...
> > Hello,
> >
> > I have a button that starts up a Thread and runs it in the background.
> >
> > While the Thread is running, all the Ajax controls, including the events
> > fired by the PageRequestManager, stop firing until the Thread exits.  So, 
> > I
> > have no way of updating the page while this Thread is running, which was 
> > the
> > point of putting it on the Thread.
> >
> > The Ajax timer stops firing.  Nothing works.  It's very frustrating.
> >
> > Can someone please help me?
> >
> > Thanks,
> >
> > Amrit Kohli 
> 
> 
> 
Date:Tue, 31 Jul 2007 10:12:02 -0700   Author:  

Re: Everything stops when a Thread is running on the server   
John,

I was using the Session to pass values back to the Progress Bar.  However, I 
stopped doing that.  I now use a static variable to do the same thing.  There 
are other alternatives like a hidden field, but I'm okay with the static 
field.

My last post explains how I fixed this problem.  

Thanks for the response.

Amrit

"John Saunders [MVP]" wrote:


> "Amrit Kohli" <Amrit Kohli@discussions.microsoft.com> wrote in message 
> news:A7A36A8A-002A-4D9B-AA95-F5F20CCE8B40@microsoft.com...
> > Hello,
> >
> > I have a button that starts up a Thread and runs it in the background.
> >
> > While the Thread is running, all the Ajax controls, including the events
> > fired by the PageRequestManager, stop firing until the Thread exits.  So, 
> > I
> > have no way of updating the page while this Thread is running, which was 
> > the
> > point of putting it on the Thread.
> >
> > The Ajax timer stops firing.  Nothing works.  It's very frustrating.
> >
> > Can someone please help me?
> 
> Are you using Session state? I've recently read that requests for the same 
> session are serialized.
> 
> BTW, I hope your background thread doesn't reference anything in the Page or 
> Request, or any other part of the HttpContext. Once the page unloads, all of 
> that data is invalid, even if your thread is still accessing it.
> -- 
> John Saunders [MVP]
> 
> 
Date:Tue, 31 Jul 2007 10:14:03 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us