By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,470 Members | 924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,470 IT Pros & Developers. It's quick & easy.

threading

P: n/a
Hi

I am trying to thread a large process to show the user a 'processing' gif
while this thread loads

what i have done, is create a submit_click method and set it to be a thread.
In the start of the thread i hide the main panel on the page, and show a
hidden image ('loading.gif')
I then create a threadstart and perform my larger process.
At the end of this larger process, i hide the 'loading.gif' and display the
main panel again.

The image shows fine at the beginning of the large process, but doesn't hide
when it is finished ... why?

sample code:

[MTAThread]
private void Submit_Click(object Sender, EventArgs e)
{
//show the loading panel
MainPanel.Visible = false;
ImagePanel.Visible = true;

//Start the larger process
ThreadStart TS = new ThreadStart(PerformAuthorisation);
Thread workerThread = new Thread(TS);
Thread.Start();
}

[MTAThread]
private void PerformAuthorisation()
{
//large processing goes here

//Show the main panel again
MainPanel.Visible = true;
ImagePanel.Visible = false;
}

So, the loading panel is shown correctly in the first place, but the reverse
is never done.
Any ideas

TIA

Grant
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The nature of threads is this: Threads operate independently. What I mean by
that is, a Page class is instantiated when a Request comes from a client.
The Page class processes the Request and then is destroyed, all within a
matter of milliseconds. Now, when the Page class, in the process of
processing a Request, spawns another thread, the new thread has access to
all the properties of the class which spawned it -AS LONG AS THAT CLASS IS
ALIVE. Once the Page class terminates, it is terminated.

In other words, while this sort of thing works nicely in executables, where
state is constant, in ASP.Net, where state comes and goes in a heartbeat,
you need to account for the fact that state comes and goes in a heartbeat.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Grant Merwitz" <gr***@magicalia.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I am trying to thread a large process to show the user a 'processing' gif
while this thread loads

what i have done, is create a submit_click method and set it to be a
thread.
In the start of the thread i hide the main panel on the page, and show a
hidden image ('loading.gif')
I then create a threadstart and perform my larger process.
At the end of this larger process, i hide the 'loading.gif' and display
the main panel again.

The image shows fine at the beginning of the large process, but doesn't
hide when it is finished ... why?

sample code:

[MTAThread]
private void Submit_Click(object Sender, EventArgs e)
{
//show the loading panel
MainPanel.Visible = false;
ImagePanel.Visible = true;

//Start the larger process
ThreadStart TS = new ThreadStart(PerformAuthorisation);
Thread workerThread = new Thread(TS);
Thread.Start();
}

[MTAThread]
private void PerformAuthorisation()
{
//large processing goes here

//Show the main panel again
MainPanel.Visible = true;
ImagePanel.Visible = false;
}

So, the loading panel is shown correctly in the first place, but the
reverse is never done.
Any ideas

TIA

Grant

Nov 19 '05 #2

P: n/a
ok, that makes sense. Thanks

So how can i achieve what i set out to do now.
Showing a loading page during a large process?

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ec**************@tk2msftngp13.phx.gbl...
The nature of threads is this: Threads operate independently. What I mean
by that is, a Page class is instantiated when a Request comes from a
client. The Page class processes the Request and then is destroyed, all
within a matter of milliseconds. Now, when the Page class, in the process
of processing a Request, spawns another thread, the new thread has access
to all the properties of the class which spawned it -AS LONG AS THAT CLASS
IS ALIVE. Once the Page class terminates, it is terminated.

In other words, while this sort of thing works nicely in executables,
where state is constant, in ASP.Net, where state comes and goes in a
heartbeat, you need to account for the fact that state comes and goes in a
heartbeat.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Grant Merwitz" <gr***@magicalia.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I am trying to thread a large process to show the user a 'processing' gif
while this thread loads

what i have done, is create a submit_click method and set it to be a
thread.
In the start of the thread i hide the main panel on the page, and show a
hidden image ('loading.gif')
I then create a threadstart and perform my larger process.
At the end of this larger process, i hide the 'loading.gif' and display
the main panel again.

The image shows fine at the beginning of the large process, but doesn't
hide when it is finished ... why?

sample code:

[MTAThread]
private void Submit_Click(object Sender, EventArgs e)
{
//show the loading panel
MainPanel.Visible = false;
ImagePanel.Visible = true;

//Start the larger process
ThreadStart TS = new ThreadStart(PerformAuthorisation);
Thread workerThread = new Thread(TS);
Thread.Start();
}

[MTAThread]
private void PerformAuthorisation()
{
//large processing goes here

//Show the main panel again
MainPanel.Visible = true;
ImagePanel.Visible = false;
}

So, the loading panel is shown correctly in the first place, but the
reverse is never done.
Any ideas

TIA

Grant


Nov 19 '05 #3

P: n/a
Google "ASP.Net Progress"

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Grant Merwitz" <gr***@magicalia.com> wrote in message
news:ug***************@TK2MSFTNGP09.phx.gbl...
ok, that makes sense. Thanks

So how can i achieve what i set out to do now.
Showing a loading page during a large process?

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ec**************@tk2msftngp13.phx.gbl...
The nature of threads is this: Threads operate independently. What I mean
by that is, a Page class is instantiated when a Request comes from a
client. The Page class processes the Request and then is destroyed, all
within a matter of milliseconds. Now, when the Page class, in the process
of processing a Request, spawns another thread, the new thread has access
to all the properties of the class which spawned it -AS LONG AS THAT
CLASS IS ALIVE. Once the Page class terminates, it is terminated.

In other words, while this sort of thing works nicely in executables,
where state is constant, in ASP.Net, where state comes and goes in a
heartbeat, you need to account for the fact that state comes and goes in
a heartbeat.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Grant Merwitz" <gr***@magicalia.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi

I am trying to thread a large process to show the user a 'processing'
gif while this thread loads

what i have done, is create a submit_click method and set it to be a
thread.
In the start of the thread i hide the main panel on the page, and show a
hidden image ('loading.gif')
I then create a threadstart and perform my larger process.
At the end of this larger process, i hide the 'loading.gif' and display
the main panel again.

The image shows fine at the beginning of the large process, but doesn't
hide when it is finished ... why?

sample code:

[MTAThread]
private void Submit_Click(object Sender, EventArgs e)
{
//show the loading panel
MainPanel.Visible = false;
ImagePanel.Visible = true;

//Start the larger process
ThreadStart TS = new ThreadStart(PerformAuthorisation);
Thread workerThread = new Thread(TS);
Thread.Start();
}

[MTAThread]
private void PerformAuthorisation()
{
//large processing goes here

//Show the main panel again
MainPanel.Visible = true;
ImagePanel.Visible = false;
}

So, the loading panel is shown correctly in the first place, but the
reverse is never done.
Any ideas

TIA

Grant



Nov 19 '05 #4

P: n/a
Grant Merwitz wrote:
Hi

I am trying to thread a large process to show the user a 'processing' gif
while this thread loads

what i have done, is create a submit_click method and set it to be a thread.
In the start of the thread i hide the main panel on the page, and show a
hidden image ('loading.gif')
I then create a threadstart and perform my larger process.
At the end of this larger process, i hide the 'loading.gif' and display the
main panel again.

The image shows fine at the beginning of the large process, but doesn't hide
when it is finished ... why?

sample code:

[MTAThread]
private void Submit_Click(object Sender, EventArgs e)
{
//show the loading panel
MainPanel.Visible = false;
ImagePanel.Visible = true;

//Start the larger process
ThreadStart TS = new ThreadStart(PerformAuthorisation);
Thread workerThread = new Thread(TS);
Thread.Start();
}

[MTAThread]
private void PerformAuthorisation()
{
//large processing goes here

//Show the main panel again
MainPanel.Visible = true;
ImagePanel.Visible = false;
}

So, the loading panel is shown correctly in the first place, but the reverse
is never done.
Any ideas

TIA

Grant

You should definitely check out Rob Howard's stuff about lengthy processes!
Go to www.rob-howard.net and grab the slides and demos from the
Blackbelt TechEd 2004 presentation.

//Rutger
Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.