why reading from a file in webforms application using StreamReader class dose not block the browser?

While making so in a windows form application the application got frozen tell the reading ends note :I am using Thread.Sleep()
6 Replies
jcotton42
jcotton423mo ago
The browser? As in a web view in the app? Please provide more details.
steven preadly
steven preadly3mo ago
Webforms is an old technology unfortunately I am working In a company that is still using it,its extension .aspx yes I will send a sample of the code
//Webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Proccessing" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="ClickMe" OnClick="Button2_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>

</form>
</body>
</html>
//Webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Proccessing" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="ClickMe" OnClick="Button2_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>

</form>
</body>
</html>
c#
//Webform1.aspx.cs
using System;
using System.IO;
using System.Threading;

namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{

private string _count = default;

protected void Page_Load(object sender, EventArgs e)
{

}


private void CharacterCount()
{
string file = @"D:\Projects\AutherizationAndAuthentication\storage\logs\laravel.log";

using (StreamReader sr = new StreamReader(file))
{
string Content = sr.ReadToEnd();

_count = Content.Length.ToString();
}

}


protected void Button1_Click(object sender, EventArgs e)
{


CharacterCount();

Label1.Text = "Proccessing...";

Thread.Sleep(5000);

Label1.Text = "The Number Of Chars In File Is " + _count;
}

protected void Button2_Click(object sender, EventArgs e)
{


}
}
}
c#
//Webform1.aspx.cs
using System;
using System.IO;
using System.Threading;

namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{

private string _count = default;

protected void Page_Load(object sender, EventArgs e)
{

}


private void CharacterCount()
{
string file = @"D:\Projects\AutherizationAndAuthentication\storage\logs\laravel.log";

using (StreamReader sr = new StreamReader(file))
{
string Content = sr.ReadToEnd();

_count = Content.Length.ToString();
}

}


protected void Button1_Click(object sender, EventArgs e)
{


CharacterCount();

Label1.Text = "Proccessing...";

Thread.Sleep(5000);

Label1.Text = "The Number Of Chars In File Is " + _count;
}

protected void Button2_Click(object sender, EventArgs e)
{


}
}
}
jcotton42
jcotton423mo ago
Oh WebForms, I thought you said WinForms. I got no idea 🤷‍♂️
steven preadly
steven preadly3mo ago
i know it very old but stell being used in here do you have any clue about this
jcotton42
jcotton423mo ago
I do not, I only touched WebForms once and it was something I tried to forget 😅
steven preadly
steven preadly3mo ago
that my destiny
Want results from more Discord servers?
Add your server