如何在代码隐藏功能中执行PAUSE? [英] how to do a PAUSE in an codebehind function?

查看:64
本文介绍了如何在代码隐藏功能中执行PAUSE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望暂停一个功能,然后在30秒内恢复。

我知道这听起来很奇怪...我有一种情况需要写一个cookie,

但是用户在asp.net页面加载时没有权限驱动,并且我认为这会阻止cookie被写入。我需要

代码暂停,然后在30秒内写下cookie .....


任何人都知道是否可以这样做?

TY

jason shohet

解决方案

Jason Shohet写道:

我希望一个功能暂停,然后在30秒内恢复。
我知道这听起来很奇怪...我有一种情况需要写一个cookie,
但用户没有在asp.net页面加载的时候开车的权利,我认为这会阻止编写cookie。我需要暂停代码,然后在30秒内写下cookie .....

任何人都知道是否可以这样做?
TY
jason shohet




我相信你可以通过获取当前线程的引用

来满足您的请求并让它睡眠:


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


我很确定arg是毫秒,请验证。


-

Craig Deelsnyder

Microsoft MVP - ASP / ASP.NET


System.Threading.Thread.Current.Sleep(不确定确切名称但是

应该关闭)。


哪个驾驶 ?通常,cookie只在一个位置处于客户端处理IE

必须要关心。用户可以从多个级别的安全性中选择

用于cookie(最多不包含任何cookie,在这种情况下,您不太可能为某些东西提供
)。 AFAIK如果您提供有关使用

cookies的更多信息,您应该可以在某些限制级别工作...


Patrice
-


Jason Shohet < __ ****** @ yahoo.com>一个écritdansle message de

新闻:Oo ************** @ TK2MSFTNGP12.phx.gbl ...

我想要暂停的功能,然后在30秒内恢复。
我知道这听起来很奇怪...我有一种情况需要写一个
的cookie,但用户没有权利开车加载asp.net页面的时间,我认为这样可以防止写入cookie。我b $ b需要代码暂停,然后在30秒内写下cookie .....

任何人都知道这可以做到吗?
TY
jason shohet



Jason,


正如另一张海报所提到的,客户端网络上的cookie到磁盘浏览器。

当他们离开服务器时,它们只是一个HTTP标头,如下所示:

Set-Cookie:NAME = VALUE;期满= DATE;路径= PATH;域= DOMAIN_NAME;安全


然后浏览器决定如何处理该文本(如果有的话)。饼干

也以相同的方式发送回服务器。


因此,导致页面进入睡眠状态绝对没有任何作用。请

提供更具体的信息。


-

Alex Papadimoulis
http://weblogs.asp.net/Alex_Papadimoulis

" Jason Shohet" < __ ****** @ yahoo.com>在消息中写道

新闻:Oo ************** @ TK2MSFTNGP12.phx.gbl ...

我想要一个函数暂停,然后在30秒内恢复。
我知道这听起来很奇怪...我有一种情况需要写一个
cookie,但是用户没有权利在asp时开车.net页面
加载,我认为这是在阻止编写cookie。我b $ b需要代码暂停,然后在30秒内写下cookie .....

任何人都知道这可以做到吗?
TY
jason shohet



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

解决方案

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


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



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



这篇关于如何在代码隐藏功能中执行PAUSE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆