[RESOLVED] Preventing window from freezing in .net Framework 3.5
I have a process that's taking long time and the window freezes until the operation finishes. Here's my code:
button function
VB.NET Code:
...
proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "install.bat",
// Arguments = "command line arguments to your executable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = await proc.StandardOutput.ReadLineAsync();
// do something with line
info_lbl.Text = line;
}
...
Here ReadLineAsync is underlined with red line and telling me I can't use ReadLineAsync.
Re: Preventing window from freezing in .net Framework 3.5
ReadLineAsync was added in .NET 4.5. The Task class didn't even get added until .NET 4.0. In .NET 3.5, you could use a BackgroundWorker or implement your own multi-threading.
Re: Preventing window from freezing in .net Framework 3.5
That works like a charm. Thanks a lot!