473,378 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to do a PAUSE in an codebehind function?

I want a function to pause, then resume in 30 seconds.
I know it sounds wierd... I have a situation that I need to write a cookie,
but the user does not have rights to drive at the time the asp.net page
loads, and I think this is preventing the cookie from being written. I need
the code to pause, then in 30 seconds write the cookie.....

anyone know if this can be done?
TY
jason shohet
Nov 18 '05 #1
14 9281
Jason Shohet wrote:
I want a function to pause, then resume in 30 seconds.
I know it sounds wierd... I have a situation that I need to write a cookie,
but the user does not have rights to drive at the time the asp.net page
loads, and I think this is preventing the cookie from being written. I need
the code to pause, then in 30 seconds write the cookie.....

anyone know if this can be done?
TY
jason shohet


I believe you can do this by getting a reference to the current thread
for your request and have it sleep:

System.Threading.Thread.Current.Sleep(30 * 1000);

I'm pretty sure that arg is milliseconds, please verify.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2
System.Threading.Thread.Current.Sleep (unsure about the exact name but
should be close).

Which drive ? Usually, cookies are handled client side in a location only IE
has to care about. A user is able to choose from several level of security
for cookies (up to no cookies at all in which case you are unlikely able to
to something). AFAIK if you rpovide more information about your usage of
cookies you should be able to work in some of the restrictred levels...

Patrice
--

"Jason Shohet" <__******@yahoo.com> a écrit dans le message de
news:Oo**************@TK2MSFTNGP12.phx.gbl...
I want a function to pause, then resume in 30 seconds.
I know it sounds wierd... I have a situation that I need to write a cookie, but the user does not have rights to drive at the time the asp.net page
loads, and I think this is preventing the cookie from being written. I need the code to pause, then in 30 seconds write the cookie.....

anyone know if this can be done?
TY
jason shohet

Nov 18 '05 #3
Jason,

As the other poster mentioned, cookies to disk by the client web browser.
When they leave the server, they appear simply as a HTTP Header, like this:
Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure

The browser then decides what to do with that text (if anything). Cookies
are also sent back to the server in the same manner.

Therefore, causing the page to Sleep will do absolutely nothing. Please
provide more specific infomation.

--
Alex Papadimoulis
http://weblogs.asp.net/Alex_Papadimoulis
"Jason Shohet" <__******@yahoo.com> wrote in message
news:Oo**************@TK2MSFTNGP12.phx.gbl...
I want a function to pause, then resume in 30 seconds.
I know it sounds wierd... I have a situation that I need to write a cookie, but the user does not have rights to drive at the time the asp.net page
loads, and I think this is preventing the cookie from being written. I need the code to pause, then in 30 seconds write the cookie.....

anyone know if this can be done?
TY
jason shohet

Nov 18 '05 #4
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the browser,
the cookie cannot be written to the HD ( which doesn't occur for another 15
seconds aprox). My thinking was, cookies get written to IE's folder. If
that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...
Nov 18 '05 #5
Is the script launched under the user identity ? (how it is hidden, non
interactive mode ?)

If IE is able to connect to your page, it 's really unlikely it would be
unable to write cookies because it's startup. IMO it could write actually in
another profile.

Patrice
--

"Jason Shohet" <__******@yahoo.com> a écrit dans le message de
news:un**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the browser, the cookie cannot be written to the HD ( which doesn't occur for another 15 seconds aprox). My thinking was, cookies get written to IE's folder. If
that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...

Nov 18 '05 #6
thanks to you, Patrice etc.
FYI just wanted to say, it seems its:

System.Threading.Thread.Sleep(30*1000)

Note, the 'Current' word is no longer there. There is something called
CurrentThread, but it does not have the Sleep() method :)
Nov 18 '05 #7
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the browser,
the cookie cannot be written to the HD ( which doesn't occur for another 15
seconds aprox). My thinking was, cookies get written to IE's folder. If
that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...
Nov 18 '05 #8
Is the script launched under the user identity ? (how it is hidden, non
interactive mode ?)

If IE is able to connect to your page, it 's really unlikely it would be
unable to write cookies because it's startup. IMO it could write actually in
another profile.

Patrice
--

"Jason Shohet" <__******@yahoo.com> a écrit dans le message de
news:un**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the browser, the cookie cannot be written to the HD ( which doesn't occur for another 15 seconds aprox). My thinking was, cookies get written to IE's folder. If
that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...

Nov 18 '05 #9
Patrice,
I've got another way now to do it, i don't need to do it in the startup
script. It seems that the application variable %COMPUTERNAME% can be used
in the querystring to give me the machinename, when the application is
called. I'm having another issue related to this (I just posted it), but
I'm much closer now to what I want to do and don't have to worry about doing
this in a startup script. TY
Nov 18 '05 #10
thanks to you, Patrice etc.
FYI just wanted to say, it seems its:

System.Threading.Thread.Sleep(30*1000)

Note, the 'Current' word is no longer there. There is something called
CurrentThread, but it does not have the Sleep() method :)
Nov 18 '05 #11
Patrice,
I've got another way now to do it, i don't need to do it in the startup
script. It seems that the application variable %COMPUTERNAME% can be used
in the querystring to give me the machinename, when the application is
called. I'm having another issue related to this (I just posted it), but
I'm much closer now to what I want to do and don't have to worry about doing
this in a startup script. TY
Nov 18 '05 #12
Hi Jason,

Did you understand what you were told about the cookie being in a Response
header? You don't need to open a new browser instance to set a cookie on the
client machine. Just add the cookie in any Page's Response.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jason Shohet" <__******@yahoo.com> wrote in message
news:un**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the browser, the cookie cannot be written to the HD ( which doesn't occur for another 15 seconds aprox). My thinking was, cookies get written to IE's folder. If
that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...

Nov 18 '05 #13
Well I gather, that after code has executing on the server, the page is
going back to the client. The page has a header, and the cookie is
contained in that http header. Then the browser decides to save it, or
whatever. We use cookies all over the place, writing them, reading them,
normally we don't need to start up a separate browser session. The problem
here is that we wanted a cookie to write the machinename -- AND, we do not
have netbios on the desktops, so we can only get that machine name from an
app variable.
An app variable is available at startup (starting up the computer) that
contains this computer name, and thats the only place we figured we can get
this cookie written -- way before the user has even opened the application.
So we were going to open the app silently (hidden) during startup, write the
cookie, and then close the app.

Then when the user goes into the app later on, the cookie is there and we
can read it. But we found another solution. It turns out though, that we
found that the %COMPUTERNAME% app variable is always avail. on the user's
machine, even after startup, and it can be used in the querystring. So
we're able to call the app like:
http://myapp/default.aspx?computername=%COMPUTERNAME%

And i've got it working this way.... jason shohet


When they leave the server, they appear simply as a HTTP Header, like this:
Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure

The browser then decides what to do with that text (if anything). Cookies
are also sent back to the server in the same manner.

Therefore, causing the page to Sleep will do absolutely nothing. Please
provide more specific infomation.

Hi Jason,

Did you understand what you were told about the cookie being in a Response
header? You don't need to open a new browser instance to set a cookie on the client machine. Just add the cookie in any Page's Response.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jason Shohet" <__******@yahoo.com> wrote in message
news:un**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine
starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the

browser,
the cookie cannot be written to the HD ( which doesn't occur for another

15
seconds aprox). My thinking was, cookies get written to IE's folder. If that folder is not accessible for a particular amount of time, I can try
waiting around, then writing the cookie 30 sec later...


Nov 18 '05 #14
Okay, now try it out on the Internet, on a published site.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jason Shohet" <__******@yahoo.com> wrote in message
news:uy**************@TK2MSFTNGP10.phx.gbl...
Well I gather, that after code has executing on the server, the page is
going back to the client. The page has a header, and the cookie is
contained in that http header. Then the browser decides to save it, or
whatever. We use cookies all over the place, writing them, reading them,
normally we don't need to start up a separate browser session. The problem here is that we wanted a cookie to write the machinename -- AND, we do not
have netbios on the desktops, so we can only get that machine name from an
app variable.
An app variable is available at startup (starting up the computer) that
contains this computer name, and thats the only place we figured we can get this cookie written -- way before the user has even opened the application. So we were going to open the app silently (hidden) during startup, write the cookie, and then close the app.

Then when the user goes into the app later on, the cookie is there and we
can read it. But we found another solution. It turns out though, that we
found that the %COMPUTERNAME% app variable is always avail. on the user's
machine, even after startup, and it can be used in the querystring. So
we're able to call the app like:
http://myapp/default.aspx?computername=%COMPUTERNAME%

And i've got it working this way.... jason shohet


When they leave the server, they appear simply as a HTTP Header, like this: Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
The browser then decides what to do with that text (if anything). Cookies
are also sent back to the server in the same manner.

Therefore, causing the page to Sleep will do absolutely nothing. Please
provide more specific infomation.

Hi Jason,

Did you understand what you were told about the cookie being in a Response
header? You don't need to open a new browser instance to set a cookie on

the
client machine. Just add the cookie in any Page's Response.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jason Shohet" <__******@yahoo.com> wrote in message
news:un**************@TK2MSFTNGP12.phx.gbl...
Thanks guys. To answer, this is what is happening. There's a startup
routine that occurs when a user logs on to their machine. That routine starts a browser (hidden), which will write a cookie onto the user's
machine. Thats what we want to do...

Yesterday we tried it, and the thing would not write the cookie. Our
hypothesis was that at the time the startup routine is opening the

browser,
the cookie cannot be written to the HD ( which doesn't occur for another
15
seconds aprox). My thinking was, cookies get written to IE's folder.

If that folder is not accessible for a particular amount of time, I can

try waiting around, then writing the cookie 30 sec later...



Nov 18 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
2
by: exshige | last post by:
I read from some book that you can actually on any tag in the html page put a onClick or something and assign it with the sub/function name that is in the codebehind. I tried but it say name...
4
by: Rob Shorney | last post by:
Hi, I am using .Net 2003 , c# asp.net. The situation i have is this. I have a asp.net page which in the codebehind maintains an xml document in memory. The user can click on a button to popup a...
38
by: Jackie | last post by:
I just want the programme to stop for a while. Thanks.
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
0
by: steveyjg | last post by:
I'm trying to call a function that will pause execution for 30 seconds and have a counter timer counting to 30 seconds during this pause. When the counter hits 30 execution of the program will...
8
by: Lloydm | last post by:
I've used the command "pause" in batch files which works ok but I guess it's applied dirrently in c++. Using Dev C++ 4.0 and the following is my code #include<iostream> #include<iomanip>...
3
by: nma | last post by:
Hi This code goes well with play, stop and fullscreen button, the only thing is the pause button is not there. How to make pause button? I try to make pause button but when it streams video, when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.