1

I have a WPF project, when you click on a button, a Console application window Appears and do a long task (crawling some url that it got it from the wpf window). All of this works good, I have 2 problems.

  1. while the Console window is on, the WPF window freezes.
  2. if I closed the Console window, the whole application closes (including the wpf window).

For the Console Window, I implemented the class from John Leidegren in this post: No output to console from a WPF application?

then from my WPF project:

        public void StartCrawler (string url)
        {
        ConsoleManager.Show();
        Console.BufferHeight = Int16.MaxValue - 1;
        Console.SetWindowSize(122, 54);
          //using methods to display and crawl the given site
          //showing Console Messages for users with which sites are crowled  

        }

Is there any way to unfreeze my WPF project and when the Console window closes it doesn't affect it ? apart from creating a Console Application project and refer to its .exe ?

Thanks in advance.

Community
  • 1
  • 1
Mark
  • 218
  • 1
  • 4
  • 12
  • Your question is not really clear. What does actually happen? There's a method called Hide in the code in the linked answer, does that not work? What's that about freezing? If you're starting a long running task on the UI thread that's to be expected, you'll need to run it in a background thread probably but it's hard to tell without more details. – Alex Paven Aug 22 '13 at 11:42
  • Code works as expected, the problem is when I close the Console application , the whole application closes , the WPF application closes, I just want the Console application closes without closing the entire solution. thats my main question. the other question about freezing, I am working on it now, trying to make the console works on a background thread. – Mark Aug 22 '13 at 11:59
  • 1
    Ok then, see if http://stackoverflow.com/questions/10415807/output-console-writeline-from-wpf-windows-applications-to-actual-console/10416180#10416180 helps – Alex Paven Aug 22 '13 at 12:02
  • Nice one, but it hides/kill it After it finish it's tasks, what if user closes the Console window while it still working on it's tasks ? the whole application will be terminated still :) – Mark Aug 22 '13 at 12:08
  • Ah true; not sure if this will work but try setting the application shutdown mode so that it only shuts down when the last window closes? – Alex Paven Aug 22 '13 at 12:10

0 Answers0