using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Task task = new Task(ProcessDataAsync);
task.Start();
//task.Wait();
string sd = "window.open('webform2.aspx', '_blank', 'toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400')";
ScriptManager.RegisterStartupScript(this, GetType(), "kkk", sd, true);
}
private async void ProcessDataAsync()
{
int count = 0;
using (StreamReader reader = new StreamReader("D:\\enable1.txt"))
{
string v = await reader.ReadToEndAsync();
// ... Process the file data somehow.
count += v.Length;
// ... A slow-running computation.
// Dummy code.
for (int i = 0; i < 10000; i++)
{
int x = v.GetHashCode();
if (x == 0)
{
count--;
}
}
}
}
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Task task = new Task(ProcessDataAsync);
task.Start();
//task.Wait();
string sd = "window.open('webform2.aspx', '_blank', 'toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400')";
ScriptManager.RegisterStartupScript(this, GetType(), "kkk", sd, true);
}
private async void ProcessDataAsync()
{
int count = 0;
using (StreamReader reader = new StreamReader("D:\\enable1.txt"))
{
string v = await reader.ReadToEndAsync();
// ... Process the file data somehow.
count += v.Length;
// ... A slow-running computation.
// Dummy code.
for (int i = 0; i < 10000; i++)
{
int x = v.GetHashCode();
if (x == 0)
{
count--;
}
}
}
}
}
}