I would like to solve a specific question I got, so this question is more likelly a discussion.
我想解决一个我得到的具体问题,所以这个问题更有利于讨论。
Basiclly, there is an asp.net project with a WebForm1.aspx, with a button on it. As soon as the clien press the button a thread is launch, and inmediatlly then, there is a Response.Redirect like this:
基本上,有一个带有WebForm1.aspx的asp.net项目,上面有一个按钮。一旦客户按下按钮,线程就会启动,然后就会有一个响应,就像这样有一个Response.Redirect:
protected void Button1_Click(object sender, EventArgs e)
{
BL.Class1 cd = new BL.Class1();
cd.Run(); // or cd.AsyncRun();
Response.Redirect("~/WebForm2.aspx",true);
}
Of course evrything should be nonstatic. Bussiness Logic class looks somthing like this:
当然,evrything应该是非静态的。 Bussiness Logic类看起来像这样:
public class Class1
{
public int Signal = 0;
// non blocking Run... the webserver continues with this process running backwards
public void RunAsync()
{
Signal = 0;
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(100000); // simulate heavy task!
}
).Start();
Signal = 1;
}
// blocking Run...
public void Run()
{
Signal = 0;
System.Threading.Thread.Sleep(100000); // simulate heavy task!
Signal = 1;
}
}
With this in mind, here is the discussion: - In WebForm2.aspx I would like to pool either from the client (javascript/ajax/nonstatic webservice) or the server to the client (registerscript with scriptmanager), in order to have the "Signal" variable set to "True" after the heavy process.. and tell the user (via a div with red background to green color) or something else. - If so, how would be the best method if I do not want to use SignalR or Node.js or WebApi or WebSockets jet? - Do you have any document, book where to explain such situation in an MVC project approach?
考虑到这一点,这里是讨论: - 在WebForm2.aspx我想从客户端(javascript / ajax / nonstatic webservice)或服务器到客户端(带脚本管理器的registercript)池,以便拥有“在繁重的过程之后将信号“变量”设置为“真”,并告诉用户(通过红色背景为绿色的div)或其他内容。 - 如果是这样,如果我不想使用SignalR或Node.js或WebApi或WebSockets喷射器,那么最好的方法是什么? - 您是否有任何文件,书籍在MVC项目方法中解释这种情况?
All communitty, really thanked on helping within this issue.
所有社区都非常感谢在这个问题上提供帮助。
br,
BR,
1 个解决方案
#1
1
Sounds like a simple meta refresh would do the trick, or a JavaScript that reloads the page on a set interval - no need for anything fancy if you don't want to.
听起来像一个简单的元刷新就可以了,或者是一个在设定的时间间隔内重新加载页面的JavaScript - 如果你不想要的话,不需要任何花哨的东西。
Simply render the page (server-side) either with a red or a green div depending on the completion status of the heavy job.
只需使用红色或绿色div渲染页面(服务器端),具体取决于繁重作业的完成状态。
#1
1
Sounds like a simple meta refresh would do the trick, or a JavaScript that reloads the page on a set interval - no need for anything fancy if you don't want to.
听起来像一个简单的元刷新就可以了,或者是一个在设定的时间间隔内重新加载页面的JavaScript - 如果你不想要的话,不需要任何花哨的东西。
Simply render the page (server-side) either with a red or a green div depending on the completion status of the heavy job.
只需使用红色或绿色div渲染页面(服务器端),具体取决于繁重作业的完成状态。