Results 1 to 3 of 3

Thread: [RESOLVED] Preventing window from freezing in .net Framework 3.5

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    200

    Resolved [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:
    1. ...
    2. proc = new Process
    3. {
    4.     StartInfo = new ProcessStartInfo
    5.     {
    6.         FileName = "install.bat",
    7.         // Arguments = "command line arguments to your executable",
    8.         UseShellExecute = false,
    9.         RedirectStandardOutput = true,
    10.         CreateNoWindow = true
    11.     }
    12. };
    13. proc.Start();
    14. while (!proc.StandardOutput.EndOfStream)
    15. {
    16.     string line = await proc.StandardOutput.ReadLineAsync();
    17.     // do something with line
    18.     info_lbl.Text = line;
    19. }
    20. ...

    Here ReadLineAsync is underlined with red line and telling me I can't use ReadLineAsync.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    200

    Re: Preventing window from freezing in .net Framework 3.5

    That works like a charm. Thanks a lot!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width